Skip to content

Instantly share code, notes, and snippets.

@llelf
Created August 19, 2012 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llelf/3397364 to your computer and use it in GitHub Desktop.
Save llelf/3397364 to your computer and use it in GitHub Desktop.
fpfp-august
import Control.Monad.Logic
import Data.List
foo :: Logic Bool
foo = do [c2,c3,c4,c5,c6,c7,cJ,cA] <- sequence . replicate 8 $ return True `mplus` return False
guard $ c3 `thinks` sane cA
guard $ c4 `thinks` not (not (sane c2) && not (sane c3))
guard $ c5 `thinks` sane cA == sane c4
guard $ c6 `thinks` sane cA && sane c2
guard $ c7 `thinks` not (sane c5)
guard $ cJ `thinks` not (not (sane c6) && not (sane c7))
return cJ
where a `thinks` b = a == b
sane a = a
answer = nub $ observeAll foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment