Skip to content

Instantly share code, notes, and snippets.

@fumieval
Created August 29, 2011 07:34
Show Gist options
  • Select an option

  • Save fumieval/1177948 to your computer and use it in GitHub Desktop.

Select an option

Save fumieval/1177948 to your computer and use it in GitHub Desktop.
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