| Copyright | (c) dramforever 2017 |
|---|---|
| License | BSD3 |
| Maintainer | dramforever |
| Stability | experimental |
| Portability | non-portable (Template Haskell) |
| Safe Haskell | None |
| Language | Haskell2010 |
Each
Description
The basic structure of an each block is this:
$(each [| ... |])
Inside of this block, three (interchangable) ways are used to mark impure subexpressions:
bind expr
bind $ expr
(~! expr)
When each encounters such a subexpression, appropriate calls to fmap,
<*> and join are generated so that the results generally match what you
would expect. In particular, The impure actions are evaluated from left to
right, so that:
$(each [| bind getLine ++ bind getLine ])
means
(++) `fmap` getLine <*> getLine
Type signatures
Type signatures like (x :: t), when used on expressions containing bind,
i.e. impure subexpressions, are transformed in one of the following ways:
- With
PartialTypeSignatures, the generated context type will be a wildcard, requiring GHC to infer the context. In this case(z :: t)where contains an impure subexpression, is transfomed into(z' :: _ t), wherez'is the transformed form ofz. - With
eachWith, the context type is as supplied. For examples seeeachWith.
Documentation
Do not use this outside of an each block. Only its name is used, and its value itself does not make sense.