Safe Haskell | Safe |
---|---|

Language | Haskell98 |

- data T w s a
- constant :: (C w, C a) => a -> T w s a
- fromVariable :: Variable w s a -> T w s a
- fromRule1 :: (C w, C a) => (Variable w s a -> T w s ()) -> T w s a
- fromRule2 :: (C w, C b) => (Variable w s a -> Variable w s b -> T w s ()) -> T w s a -> T w s b
- fromRule3 :: (C w, C c) => (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, C a) => Apply w s (Variable w s a -> T w s ()) -> T w s a
- (=:=) :: C w => T w s a -> T w s a -> T w s ()
- (=!=) :: C w => T w s a -> T w s a -> T w s a
- sqr :: (C w, C a, Floating a) => T w s a -> T w s a
- sqrt :: (C w, C a, Floating a) => T w s a -> T w s a
- max :: (C w, Ord a, C a) => T w s a -> T w s a -> T w s a
- maximum :: (C w, Ord a, C a) => [T w s a] -> T w s a
- pair :: (C w, C a, C b) => 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.

(C w, C a, Fractional a) => Fractional (T w s a) Source # | |

(C w, C a, Fractional a) => Num (T w s a) Source # | |

# Construct primitive expressions

constant :: (C w, C a) => a -> T w s a Source #

Make a constant expression of a simple numeric value.

fromVariable :: Variable w s a -> T w s a Source #

# Operators from rules with small numbers of arguments

fromRule2 :: (C w, C b) => (Variable w s a -> Variable w s b -> T w s ()) -> T w s a -> T w s b Source #

fromRule3 :: (C w, C c) => (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!