module ToySolver.Data.LBool
( LBool (..)
, lTrue
, lFalse
, lUndef
, lnot
, liftBool
, unliftBool
) where
import Data.Int
newtype LBool = LBool Int8 deriving LBool -> LBool -> Bool
(LBool -> LBool -> Bool) -> (LBool -> LBool -> Bool) -> Eq LBool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LBool -> LBool -> Bool
$c/= :: LBool -> LBool -> Bool
== :: LBool -> LBool -> Bool
$c== :: LBool -> LBool -> Bool
Eq
{-# INLINE lTrue #-}
lTrue :: LBool
lTrue :: LBool
lTrue = Int8 -> LBool
LBool Int8
1
{-# INLINE lFalse #-}
lFalse :: LBool
lFalse :: LBool
lFalse = Int8 -> LBool
LBool (-Int8
1)
{-# INLINE lUndef #-}
lUndef :: LBool
lUndef :: LBool
lUndef = Int8 -> LBool
LBool Int8
0
{-# INLINE lnot #-}
lnot :: LBool -> LBool
lnot :: LBool -> LBool
lnot LBool
x
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lTrue = LBool
lFalse
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lFalse = LBool
lTrue
| Bool
otherwise = LBool
lUndef
{-# INLINE liftBool #-}
liftBool :: Bool -> LBool
liftBool :: Bool -> LBool
liftBool Bool
True = LBool
lTrue
liftBool Bool
False = LBool
lFalse
{-# INLINE unliftBool #-}
unliftBool :: LBool -> Maybe Bool
unliftBool :: LBool -> Maybe Bool
unliftBool LBool
x
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lTrue = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lFalse = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False
| Bool
otherwise = Maybe Bool
forall a. Maybe a
Nothing
instance Show LBool where
show :: LBool -> String
show LBool
x
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lTrue = String
"lTrue"
| LBool
x LBool -> LBool -> Bool
forall a. Eq a => a -> a -> Bool
== LBool
lFalse = String
"lFalse"
| Bool
otherwise = String
"lUndef"