unique-logic-0.4.0.1: Solve simple simultaneous equations
Safe HaskellSafe-Inferred
LanguageHaskell98

UniqueLogic.ST.Expression

Synopsis

Documentation

data T w s a Source #

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.

Instances

Instances details
(C w, C a, Fractional a) => Num (T w s a) Source # 
Instance details

Defined in UniqueLogic.ST.Expression

Methods

(+) :: T w s a -> T w s a -> T w s a #

(-) :: T w s a -> T w s a -> T w s a #

(*) :: T w s a -> T w s a -> T w s a #

negate :: T w s a -> T w s a #

abs :: T w s a -> T w s a #

signum :: T w s a -> T w s a #

fromInteger :: Integer -> T w s a #

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

Defined in UniqueLogic.ST.Expression

Methods

(/) :: T w s a -> T w s a -> T w s a #

recip :: T w s a -> T w s a #

fromRational :: Rational -> T w s a #

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

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

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

data Apply w s f Source #

Instances

Instances details
Applicative (Apply w s) Source # 
Instance details

Defined in UniqueLogic.ST.Expression

Methods

pure :: a -> Apply w s a #

(<*>) :: Apply w s (a -> b) -> Apply w s a -> Apply w s b #

liftA2 :: (a -> b -> c) -> Apply w s a -> Apply w s b -> Apply w s c #

(*>) :: Apply w s a -> Apply w s b -> Apply w s b #

(<*) :: Apply w s a -> Apply w s b -> Apply w s a #

Functor (Apply w s) Source # 
Instance details

Defined in UniqueLogic.ST.Expression

Methods

fmap :: (a -> b) -> Apply w s a -> Apply w s b #

(<$) :: a -> Apply w s b -> Apply w s a #

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!

runApply :: (C w, C a) => Apply w s (Variable w s a -> T w s ()) -> T w s a Source #

Predicates on expressions

(=:=) :: C w => T w s a -> T w s a -> T w s () infix 0 Source #

Common operators (see also Num and Fractional instances)

(=!=) :: C w => T w s a -> T w s a -> T w s a infixl 4 Source #

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

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

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

We are not able to implement a full Ord instance including Eq superclass and comparisons, but we need to compute maxima.

maximum :: (C w, Ord a, C a) => [T w s a] -> T w s a Source #

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

Construct or decompose a pair.