egison-quote-0.2: A quasi quotes for using Egison expression in Haskell code

Portabilitynon-portable (GHC-7.4.0 for GHC's extensions)
Stabilityunstable
Maintainerkuwahara111011@gmail.com
Safe HaskellNone

Language.Egison.Quote

Description

The quasi quotes for egison expression

Synopsis

Documentation

egison :: QuasiQuoterSource

QuasiQuoter for egison expression

The format is:

 expr := [egison | <egison-expression> :: <type-signature> |]

For example, with Egison pattern matching, powerset function can be expressed easily as follows.

>>> [egison|(lambda [$l] (match-all l (Multiset Integer) [<join $l _> l])) :: [Int] -> [[Int]]|] [1..3]
[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]

Type signature is defined as follows

 <Typ> = Bool | Int | Double | Float | Char | String | [<Typ>] | (<Typ>, <Typ>, ..., <Typ>) | <Typ> -> <Typ> -> ... <Typ>

Embedded Egison expression is run-time evaluated by using eval and unsafePerformIO. For more detailed usage, please refer to https://github.com/xenophobia/Egison-Quote.

parseType :: Parser TypeSource

Parser for TypeSignature

pickupAntiquote :: String -> ([String], String)Source

Pick up antiquoted variables and delete notation #{~}

 "(+ #{x} y)"  ---> ([x], "(+ x y)")

parseQuote :: Parser (EgisonExpr, Type)Source

Parser for egison-quote

readQuote :: String -> ThrowsError (EgisonExpr, Type)Source

Read function for egison-quote

toHaskellExp :: EgisonExpr -> [String] -> Type -> ExpQSource

construct Exp from Egison-expression and type signature

evalEgisonTopLevelSource

Arguments

:: EgisonExpr

evaluated expression

-> [String]

variable names

-> [ExpQ]

binding expressions

-> ExpQ