module ToySolver.Data.Boolean
(
Complement (..)
, Boolean (..)
, andB
, orB
) where
infixr 3 .&&.
infixr 2 .||.
infix 1 .=>., .<=>.
class Complement a where
notB :: a -> a
class Complement a => Boolean a where
true, false :: a
(.&&.) :: a -> a -> a
(.||.) :: a -> a -> a
(.=>.), (.<=>.) :: a -> a -> a
x .=>. y = notB x .||. y
x .<=>. y = (x .=>. y) .&&. (y .=>. x)
andB :: Boolean a => [a] -> a
andB = foldr (.&&.) true
orB :: Boolean a => [a] -> a
orB = foldr (.||.) false
instance Complement Bool where
notB = not
instance Boolean Bool where
true = True
false = False
(.&&.) = (&&)
(.||.) = (||)