Maintainer | bastiaan.heeren@ou.nl |
---|---|
Stability | provisional |
Portability | portable (depends on ghc) |
Safe Haskell | None |
Language | Haskell98 |
Synopsis
- type InterpretationParser = ParserT ExprParseState Math Identity
- toStep :: Id -> InterpretationParser [Attribute] -> InterpretationParser Step
- interpret :: Expr -> Interpretation
- addWildcardConstraint :: String -> (Expr -> Bool) -> InterpretationParser ()
- pStepEq :: Id -> Interpretation -> Interpretation -> InterpretationParser Step
- (>/<) :: Interpretation -> Interpretation -> Interpretation
- (>*<) :: Interpretation -> Interpretation -> Interpretation
- (>-<) :: Interpretation -> Interpretation -> Interpretation
- (>+<) :: Interpretation -> Interpretation -> Interpretation
- (>^<) :: Interpretation -> Interpretation -> Interpretation
- (>>*<<) :: Interpretation -> Interpretation -> Interpretation
- (>>+<<) :: Interpretation -> Interpretation -> Interpretation
- (>>/<<) :: Interpretation -> Interpretation -> Interpretation
- withModulo :: (Expr -> Expr) -> InterpretationParser a -> InterpretationParser a
- pNamedStep :: Id -> Interpretation -> Interpretation -> InterpretationParser Step
- inLiberalEquationMode :: InterpretationParser a -> InterpretationParser a
- type Interpretation = [(Expr, [Attribute])]
- getMatchEnvironment :: ExprParseState -> Map String Expr
- getWildcard :: String -> InterpretationParser (Maybe Expr)
- pStepIneq :: Id -> Interpretation -> Interpretation -> InterpretationParser (RelationType, Step)
- pStep :: Id -> Interpretation -> InterpretationParser Step
- clearWildcard :: String -> InterpretationParser ()
- pStepStrongIneq' :: Id -> Interpretation -> Interpretation -> InterpretationParser Step
- defaultModulo :: Expr -> Expr
- squared :: Interpretation -> Interpretation
- sum'' :: [Interpretation] -> Interpretation
- sum' :: [Interpretation] -> Interpretation
- initialState :: ExprParseState
Documentation
toStep :: Id -> InterpretationParser [Attribute] -> InterpretationParser Step Source #
toStep p
parses p
and captures Math
and returns a Step
interpret :: Expr -> Interpretation Source #
interpret e
represents the correct interpretation of e
without any attributes assigned
addWildcardConstraint :: String -> (Expr -> Bool) -> InterpretationParser () Source #
pStepEq :: Id -> Interpretation -> Interpretation -> InterpretationParser Step Source #
pStepEq
parses a (chained) equation.
(>/<) :: Interpretation -> Interpretation -> Interpretation infixl 7 Source #
(>*<) :: Interpretation -> Interpretation -> Interpretation infixl 7 Source #
>*<
represents the correct representation of *
(>-<) :: Interpretation -> Interpretation -> Interpretation infixl 6 Source #
(>+<) :: Interpretation -> Interpretation -> Interpretation infixl 5 Source #
>+<
represents the correct interpretation of +
regardless of mistakes in the arguments
(>^<) :: Interpretation -> Interpretation -> Interpretation infixr 8 Source #
(>>*<<) :: Interpretation -> Interpretation -> Interpretation infixl 7 Source #
x >>*<< y
generates possible interpretations (correct and erroneous) for multiplying an interpretation of x with an interpretation of y,
for now we assume the interpretations x and y are monomial or binomial (because specific to Rectangle Area exercise)
(>>+<<) :: Interpretation -> Interpretation -> Interpretation infixl 5 Source #
x >>+<< y
represents the correct and erroneous interpretation of +
.
(>>/<<) :: Interpretation -> Interpretation -> Interpretation infixl 7 Source #
x >>/<< y
generates possible interpretations (correct and erroneous) for division
the erroneous interpretation consists of distributing division over multiplication, eg: (a*b2 - a2*b/2)
withModulo :: (Expr -> Expr) -> InterpretationParser a -> InterpretationParser a Source #
pNamedStep :: Id -> Interpretation -> Interpretation -> InterpretationParser Step Source #
type Interpretation = [(Expr, [Attribute])] Source #
getMatchEnvironment :: ExprParseState -> Map String Expr Source #
the match environment contains matches for wildcards
getWildcard :: String -> InterpretationParser (Maybe Expr) Source #
pStepIneq :: Id -> Interpretation -> Interpretation -> InterpretationParser (RelationType, Step) Source #
pStep :: Id -> Interpretation -> InterpretationParser Step Source #
pStep a i
parses interpretation i
and assigns attribute a
(as identifier)
We first try to see if we can match an equation e = e
then we try to see if we can match a single expression e
otherwise we try to see if we can match an equation * = e, or e = * where * is a wildcard
clearWildcard :: String -> InterpretationParser () Source #
defaultModulo :: Expr -> Expr Source #
sum'' :: [Interpretation] -> Interpretation Source #
sum'' xs
represents the correct and incorrect representation of sum
sum' :: [Interpretation] -> Interpretation Source #
sum' xs
represents correct interpretation of summation
initialState :: ExprParseState Source #