Safe Haskell | None |
---|

- pun :: QuasiQuoter

# Documentation

`>>>`

`:set -XQuasiQuotes -XViewPatterns`

`patterns`

`>>>`

`let y = Label :: Label "y"`

`>>>`

`let x = Label :: Label "x"`

`>>>`

`[pun| x y |] <- return (x .=. 3 .*. y .=. "hi" .*. emptyRecord)`

`>>>`

(3,"hi")`print (x,y)`

`expressions`

Compare with the standard way to construct records above

`>>>`

`let x = 3; y = "hi"`

`>>>`

Record{x=3,y="hi"}`[pun|x y|]`

`nesting`

Nesting is supported. The idea is that variables inside
`{ }`

are in another record. More concretely:

[pun| ab@{ a b } y z c{d} |]

as a pattern, it will bindings from an original record `x`

,
if you interpret (.) as a left-associative field lookup (as it
is in other languages):

let ab = xab a = x.ab.a b = x.ab.b y = x.y z = x.z -- c is not bound d = x.c.d

as an expression, it creates a new record which needs the variables
`ab a b y z d`

in-scope. `ab`

needs to be a record, and if it has
fields called `a`

or `b`

they are overridden by the values of `a`

and `b`

which are in scope.

See also `examples/pun.hs`

.

requires the use of Data.HList.Label6 (ie. the label for foo is `Label :: Label "foo"`

)