Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Convenient construction of bidirectional functions using case-like syntax.
Synopsis
Documentation
biCase :: QuasiQuoter Source #
Construct an expression representing a function bijection based on a set of newline- or semicolon-separated cases.
Each case should be two pattern-expressions separated by -
.
Each pattern-expression is a haskell pattern that can also be interpreted as an expression.
You can think of these as symmetric or bidirectional case expressions.
The result will be a bijection that is the combination of two lambdas, one with the cases intepreted forward, and one reverse.
For example:
newtype T a = C a biC :: T a <-> a biC = [biCase| C a <-> a |]
isJust :: Maybe () <-> Bool isJust = [biCase| Just () <-> True Nothing <-> False |]