Skip to content

Instantly share code, notes, and snippets.

@atton
Created March 28, 2014 01:49
Show Gist options
  • Save atton/9823386 to your computer and use it in GitHub Desktop.
Save atton/9823386 to your computer and use it in GitHub Desktop.
foldl and foldr on flipped Bool for infinite list
data B = T | F
deriving (Eq, Show)
(&&&) :: B -> B -> B
b &&& T = b
_ &&& F = F
(|||) :: B -> B -> B
_ ||| T = T
b ||| F = b
-- Bool
foldl (&&) False $ repeat False -- ng
foldr (&&) False $ repeat False -- ok
-- flipped bool
foldl (&&&) F $ repeat F -- ng
foldr (&&&) F $ repeat F -- ng (stack overflow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment