| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Howl.Builtins.ToBuiltin
Description
Convert Haskell functions into builtin Howl rules.
Documentation
Given a function type f, turn it into an operation on a
Seq Expr, interpreted as the arguments to a symbolic function.
We provide instances for return types that can reasonably be turned
into rules, where the final result type is any instance of
ToExpr.
Instances
| ToExpr a => ToBuiltin a # | A pure builtin that always matches its arguments. |
| ToExpr a => ToBuiltin (Eval (Maybe a)) # | A monadic builtin that may fail to match its arguments, signified
by |
| ToExpr a => ToBuiltin (Eval a) # | A monadic builtin that always matches its arguments. |
| ToExpr a => ToBuiltin (Maybe a) # | A pure builtin that may fail to match its arguments, signified by
|
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Eval (Maybe b))) # | A variadic monadic builtin that may fail to match its arguments,
signified by |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Eval b)) # | A variadic monadic builtin that always matches its arguments. |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Maybe b)) # | A variadic pure builtin that may fail to match its arguments,
signified by |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a b) # | A variadic pure builtin that always matches its arguments. |
| (FromExpr a, ToBuiltin f) => ToBuiltin (a -> f) # | Provide instances for functions of the form
Together, these instances allow us to "lift" most reasonable
Haskell functions to functions that can be used inside rules.
Here are some example types that have instances for
|
Mark a function as variadic, i.e. as taking a Seq a of arbitrary
length as its argument list.
Constructors
| MkVariadic (Seq a -> b) |
Instances
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Eval (Maybe b))) # | A variadic monadic builtin that may fail to match its arguments,
signified by |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Eval b)) # | A variadic monadic builtin that always matches its arguments. |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a (Maybe b)) # | A variadic pure builtin that may fail to match its arguments,
signified by |
| (FromExpr a, ToExpr b) => ToBuiltin (Variadic a b) # | A variadic pure builtin that always matches its arguments. |
def :: ToBuiltin f => Symbol -> f -> Eval () #
Define a builtin rule by converting a Haskell function into a Howl
definition using ToBuiltin.
builtinDecl :: ToBuiltin f => Symbol -> f -> Decl #
Convert a Haskell function into a declaration for a builtin downvalue.