åã¯ã©ã¹ã®ãã©ã¡ã¿å¤ç¸ï¼
Either a b
(ä½ãaã¨bã¯ä½ããã®å
±éã®å¶ç´ãæã¤)ã«é©ç¨ã§ãã f g = either g g
ã¨ããé¢æ°ãæ¸ããã¨ãããï¼æ¸ããªãã£ãï¼ç¹å®ã®åã¯ã©ã¹ã«éå®ããã°æ¸ããã¨ãã§ããï¼
{-# LANGUAGE RankNTypes #-} fshow :: (Show a, Show b) => (forall c. (Show c) => c -> d) -> Either a b -> d fshow g = either g g feq :: (Eq a, Eq b) => (forall c. (Eq c) => c -> d) -> Either a b -> d feq g = either g g -- f :: (k a, k b) => (forall c. (k c) => c -> d) -> Either a b -> d -- f g = either g g -- => malformed class assertion g h = print $ map h [Left 42, Right 'a'] main = g (fshow show) >> g (feq (\x -> x == x))
Show
ã Eq
ã®ã¨ããããã©ã¡ã¿ã«ããã°ããããã«æã£ãã®ã ãã©ï¼GHCã§ã¯ã³ã³ãã¤ã«ã¨ã©ã¼ã«ãªã£ã¦ãã¾ã£ãï¼ä¸ä½ã©ãããã°â¦