Created
August 29, 2011 07:34
-
-
Save fumieval/1177948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Gender = Male | Female deriving (Show, Eq) | |
| data Race = Martian | Venusian deriving (Show, Eq) | |
| answer (Venusian, Male) = id | |
| answer (Martian, Female) = id | |
| answer (Venusian, Female) = not | |
| answer (Martian, Male) = not | |
| race x = (x==).fst | |
| gender x = (x==).snd | |
| and' x y = \p -> x p && y p | |
| or' x y = \p -> x p || y p | |
| not' x = \p -> not $ x p | |
| pattern = [(Venusian, Male) | |
| ,(Martian, Female) | |
| ,(Venusian, Female) | |
| ,(Martian, Male)] | |
| p = race Venusian | |
| main = foldr (>>) (head res) (tail res) where | |
| res = map (\x -> print (x, answer x $ p x)) pattern |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment