Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Synopsis
- data T w s a
- constant :: (C w, Value w a, C s) => a -> T w s a
- fromVariable :: C s => Variable w s a -> T w s a
- fromRule1 :: (C w, Value w a, C s) => (Variable w s a -> T w s ()) -> T w s a
- fromRule2 :: (C w, Value w b, C s) => (Variable w s a -> Variable w s b -> T w s ()) -> T w s a -> T w s b
- fromRule3 :: (C w, Value w c, C s) => (Variable w s a -> Variable w s b -> Variable w s c -> T w s ()) -> T w s a -> T w s b -> T w s c
- data Apply w s f
- arg :: T w s a -> Apply w s (Variable w s a)
- runApply :: (C w, Value w a, C s) => Apply w s (Variable w s a -> T w s ()) -> T w s a
- (=:=) :: (C w, C s) => T w s a -> T w s a -> T w s ()
- (=!=) :: (C w, C s) => T w s a -> T w s a -> T w s a
- sqr :: (C w, Value w a, Floating a, C s) => T w s a -> T w s a
- sqrt :: (C w, Value w a, Floating a, C s) => T w s a -> T w s a
- max :: (C w, Ord a, Value w a, C s) => T w s a -> T w s a -> T w s a
- maximum :: (C w, Ord a, Value w a, C s) => [T w s a] -> T w s a
- pair :: (C w, Value w a, Value w b, Value w (a, b), C s) => T w s a -> T w s b -> T w s (a, b)
Documentation
An expression is defined by a set of equations and the variable at the top-level. The value of the expression equals the value of the top variable.
Construct primitive expressions
constant :: (C w, Value w a, C s) => a -> T w s a Source #
Make a constant expression of a simple numeric value.
Operators from rules with small numbers of arguments
fromRule2 :: (C w, Value w b, C s) => (Variable w s a -> Variable w s b -> T w s ()) -> T w s a -> T w s b Source #
fromRule3 :: (C w, Value w c, C s) => (Variable w s a -> Variable w s b -> Variable w s c -> T w s ()) -> T w s a -> T w s b -> T w s c Source #
Operators from rules with any number of arguments
arg :: T w s a -> Apply w s (Variable w s a) Source #
This function allows to generalize fromRule2
and fromRule3
to more arguments
using Applicative
combinators.
Example:
fromRule3 rule x y = runApply $ liftA2 rule (arg x) (arg y) = runApply $ pure rule <*> arg x <*> arg y
Building rules with arg
provides more granularity
than using auxiliary pair
rules!