linear-grammar-0.0.1.2: A simple grammar for building linear equations and inclusive inequalities.

Safe HaskellSafe
LanguageHaskell2010

Linear.Grammar

Contents

Synopsis

User-facing API

data LinAst Source

User-facing abstract syntax tree

Instances

(.+.) :: LinAst -> LinAst -> LinAst infixr 8 Source

class Coefficient x y where Source

Methods

(.*.) :: x -> y -> LinAst infixr 9 Source

multLin :: LinAst -> LinAst Source

Pushes ECoeff down the tree, leaving EAdd at the top level. After using this funciton, all ECoeff constructors LinAst parameter will be EVar.

Linear Expressions

data LinVar Source

Constructors

LinVar 

Fields

varName :: String
 
varCoeff :: Double
 

Instances

Eq LinVar Source 
Ord LinVar Source

For sorting tableaus

Show LinVar Source 
Arbitrary LinVar Source 

data LinExpr Source

Linear expressions suited for normal and standard form.

Constructors

LinExpr 

Fields

exprVars :: [LinVar]
 
exprConst :: Double
 

Instances

addLin :: LinAst -> LinExpr Source

Turns LinAst to LinExpr - should be done after multLin.

removeDupLin :: LinExpr -> LinExpr Source

Merged duplicate LinVars in a LinExpr. Should be used after addLin.

Linear Inequalities

data Ineq Source

Instances

(.==.) :: LinAst -> LinAst -> Ineq infixl 7 Source

(.<=.) :: LinAst -> LinAst -> Ineq infixl 7 Source

(.=>.) :: LinAst -> LinAst -> Ineq infixl 7 Source

Standard Form

standardForm :: Ineq -> IneqStdForm Source

Turns a user-level AST to a structurally standard from inequality.

standardize :: Ineq -> Ineq Source

Standardizes user-level inequalities - to be used before standardForm.