Portability | non-portable (GHC-7.4.0 for GHC's extensions) |
---|---|
Stability | unstable |
Maintainer | kuwahara111011@gmail.com |
Safe Haskell | None |
The quasi quotes for egison expression
- egison :: QuasiQuoter
- parseType :: Parser Type
- pickupAntiquote :: String -> ([String], String)
- parseAntiquote :: Parser ([String], String)
- parseQuote :: Parser (EgisonExpr, Type)
- readQuote :: String -> ThrowsError (EgisonExpr, Type)
- toHaskellExp :: EgisonExpr -> [String] -> Type -> ExpQ
- evalEgisonTopLevel :: EgisonExpr -> [String] -> [ExpQ] -> ExpQ
Documentation
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.
pickupAntiquote :: String -> ([String], String)Source
Pick up antiquoted variables and delete notation #{~}
"(+ #{x} y)" ---> ([x], "(+ x y)")
parseAntiquote :: Parser ([String], String)Source
Parser for pickupAntiquote
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
:: EgisonExpr | evaluated expression |
-> [String] | variable names |
-> [ExpQ] | binding expressions |
-> ExpQ |