hasbolt-extras-0.0.0.7: Extras for hasbolt library

Safe HaskellSafe
LanguageHaskell2010

Database.Bolt.Extras.Condition

Synopsis

Documentation

data Condition a Source #

Conditional expressions over type a and its mappings. Supported operations: * equality check :== * disunction :&& * conjunction :||

Typical usage: Say we have variable 'var :: a', a function 'f :: a -> b' and a value 'val :: b'. Expression 'f :== b' acts as 'f a == b' Examples:

data D = D { fld1 :: Int
           , fld2 :: String
           , fld3 :: Double
           }

d = D 42 "noononno" 1.618
d `matches` (fld1 :== 12 :&& fld2 :== "abc")
False

d `matches` (fld1 :== 42 :|| fld3 == 1.0)
True

Constructors

Eq b => (a -> b) :== b infix 4 
(Condition a) :&& (Condition a) infixr 3 
(Condition a) :|| (Condition a) infixr 2 

tautology :: Condition a Source #

Matching tautology will always succeed. > whatever matches tautology == True > -- Match is lazy: > undefined matches tautology == True

matches :: a -> Condition a -> Bool Source #

Check whether data satisfies conditions on it.

itself :: a -> a Source #

Object itself instead of its mappings is matched with help of this alias. > 42 matches (itself :== 42) == True > 42 matches (itself :== 41) == False