Skip to content

Instantly share code, notes, and snippets.

@lnicola
Created June 26, 2014 12:10
Show Gist options
  • Save lnicola/74c7c707a22f165b65e8 to your computer and use it in GitHub Desktop.
Save lnicola/74c7c707a22f165b65e8 to your computer and use it in GitHub Desktop.
module Main where
import Control.Monad
data S = C | C1 | C2 | C3 | D | O Integer deriving (Eq, Show)
data A = A | Is deriving (Eq, Show)
props = [(C3, A, O 3), (C2, A, O 2), (C1, Is, C3), (C2, Is, C3), (C, Is, C1), (C, Is, C2), (D, A, O 0)]
find f s lst = [x | x@(s', _, _) <- lst, s == s', f x] `mplus` concat [find f p lst | (s', Is, p) <- lst, s == s']
main = print $ map trd $ find f C props where
f (_, a, _) = a == A
trd (_, _, x) = x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment