ãã®ã¨ã³ããªã¯ãHaskell Advent Calendar 2011ã®åå è¨äºã§ãã ä»åã¯ãHaskellã®GHCæ¡å¼µã§ããGADTs(Generalized Algebraic Data Types : ä¸è¬å代æ°ãã¼ã¿å)ã調ã¹ã¦ä½¿ã£ã¦ã¿ãã¨ããå 容ãæ¸ãã¦ã¿ã¾ããã æåã«ãGADTsã¯GHCæ¡å¼µãªã®ã§ã使ç¨ããã«ã¯ä»¥ä¸ã®ããã«ãã¦æ¡å¼µãæå¹ã«ããå¿ è¦ãããã¾ãï¼ {-#LANGUAGE GADTs #-} ã¾ãã¯æ§æçãªéãããMaybeãä¾ã«ãã¦è¦ã¦ã¿ã¾ãããã é常ã®ä»£æ°ãã¼ã¿åã§ã¯ãMaybeã¯ä»¥ä¸ã®ããã«æ¸ãã¾ãï¼ data Maybe a = Nothing | Just a GADTsã§ã¯ä»¥ä¸ã®ããã«æ¸ãã¾ãï¼ data Maybe a where Nothing :: Maybe a Just :: a -> Maybe a é常ã®ä»£æ°ãã¼ã¿åã§ã¯ããã¼ã¿ã³ã³ã¹
{{#tags}}- {{label}}
{{/tags}}