pinchot-0.24.0.0: Write grammars, not parsers

Safe HaskellNone
LanguageHaskell2010

Pinchot.RecursiveDo

Description

Emulating recursive do notation, as TH does not support it.

Synopsis

Documentation

lazyPattern :: Foldable c => c Name -> Q Pat Source #

Creates a lazy pattern for all the given names. Adds an empty pattern onto the front. This is the counterpart of bigTuple. All of the given names are bound. In addition, a single, wildcard pattern is bound to the front.

For example, lazyPattern (map mkName ["x", "y", "z"]) gives a pattern that looks like

~(_, (x, (y, (z, ()))))

The idea is that the named patterns are needed so that the recursive do notation works, and that the wildcard pattern is the return value, which is not needed here.

bigTuple Source #

Arguments

:: Foldable c 
=> ExpQ

This expression will be the first one in the tuple.

-> c ExpQ

Remaining expressions in the tuple.

-> ExpQ 

Creates a big tuple. It is nested in the second element, such as (1, (2, (3, (4, ())))). Thus, the big tuple is terminated with a unit value. It resembles a list where each tuple is a cons cell and the terminator is unit.

recursiveDo Source #

Arguments

:: [(Name, ExpQ)]

Binding statements

-> ExpQ

Final return value from do block. The type of this ExpQ must be in the same monad as the do block; it must not be a pure value.

-> ExpQ

Returns an expression whose value is the final return value from the do block.

Builds a recursive do expression (because TH has no support for mdo notation).