Stability | experimental |
---|---|
Maintainer | conal@conal.net |
Variation of Twan van Laarhoven's simple-reflect http://hackage.haskell.org/cgi-bin/hackage-scripts/package/simple-reflect
Differences from Twan's version: + Generates pretty-printings instead of strings + No evaluation + Removed overloadings that disagree with semantic versions (e.g., '(==)') + A few stylistic tweaks
- data Expr = Expr {}
- class FromExpr a where
- lift :: PrettyPrec a => a -> Expr
- var :: String -> Expr
- fun :: FromExpr a => String -> a
- apply :: Expr -> Expr -> Expr
- ($$) :: Expr -> Expr -> Expr
- data Associativity
- op :: Associativity -> Int -> String -> Expr -> Expr -> Expr
- lambdaX :: String -> Expr -> Expr
- letX :: String -> Expr -> Expr -> Expr
- tupleX :: [Expr] -> Expr
- ccall :: String -> [Expr] -> Expr
- dotX :: String -> Expr -> Expr
- onDoc :: (Doc -> Doc) -> Expr -> Expr
- class Show a => HasExpr a where
- class HasExprU h where
- prettyExpr :: HasExpr a => Int -> a -> Doc
- docParen :: Bool -> Doc -> Doc
Construction
A reflected expression
lift :: PrettyPrec a => a -> ExprSource
data Associativity Source
This data type specifies the associativity of operators: left, right or none.
op :: Associativity -> Int -> String -> Expr -> Expr -> ExprSource
An infix operator with the given associativity, precedence and name
class Show a => HasExpr a whereSource
HasExpr Bool | |
HasExpr Char | |
HasExpr Double | |
HasExpr Float | |
HasExpr Int | |
HasExpr Integer | |
HasExpr () | |
HasExpr Doc | |
HasExpr Expr | |
(Show a, PrettyPrec a) => HasExpr [a] | |
Integral a => HasExpr (Ratio a) | |
(Show a, PrettyPrec a) => HasExpr (Maybe a) | |
HasExpr a => HasExpr (Complex a) | |
HasExpr (Type t) | |
HasExpr (ScalarT a) | |
HasExpr (E a) | |
HasExpr a => HasExpr (V a) | |
(Show a, Show b, Pretty a, Pretty b) => HasExpr (a, b) | |
(IsNat n, IsScalar a, Show a) => HasExpr (Vec n a) | |
HasExpr (VectorT n a) | |
(HasExpr a, HasExprU f) => HasExpr (Glom f a) | |
(Show a, Show b, Show c, Pretty a, Pretty b, Pretty c) => HasExpr (a, b, c) |
prettyExpr :: HasExpr a => Int -> a -> DocSource
Convenient for defining PrettyPrec
when we have a HasExpr
.