Safe Haskell | None |
---|
- ifte :: (IvoryStore a, IvoryZero (Stored a), GetAlloc eff ~ Scope s) => IBool -> Ivory eff a -> Ivory eff a -> Ivory eff a
- when :: IBool -> Ivory eff () -> Ivory eff ()
- unless :: IBool -> Ivory eff () -> Ivory eff ()
- cond_ :: [Cond eff ()] -> Ivory eff ()
- cond :: (IvoryStore a, IvoryZero (Stored a), GetAlloc eff ~ Scope s) => [Cond eff a] -> Ivory eff a
- (==>) :: IBool -> Ivory eff a -> Cond eff a
Documentation
ifte :: (IvoryStore a, IvoryZero (Stored a), GetAlloc eff ~ Scope s) => IBool -> Ivory eff a -> Ivory eff a -> Ivory eff aSource
cond_ :: [Cond eff ()] -> Ivory eff ()Source
A multi-way if. This is useful for avoiding an explosion of nesting and parentheses in complex conditionals.
Instead of writing nested chains of ifs:
ifte_ (x >? 100) (store result 10) (ifte_ (x >? 50) (store result 5) (ifte_ (x >? 0) (store result 1) (store result 0)))
You can write:
cond_ [ x >? 100 ==> store result 10 , x >? 50 ==> store result 5 , x >? 0 ==> store result 1 , true ==> store result 0 ]
Note that ==> is non-associative and has precedence 0, so you will need parentheses to call functions with $ on the left-hand side:
cond_ [ (f $ g x) ==> y ]
rather than:
cond_ [ f $ g x ==> y ]