expressions-0.5: Expressions and Formulae a la carte

Copyright(C) 2017-18 Jakub Daniel
LicenseBSD-style (see the file LICENSE)
MaintainerJakub Daniel <jakub.daniel@protonmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Expression.Parser

Description

 
Synopsis

Documentation

type Context = Map String DynamicSort Source #

Parsing context assigning sorts to known variables

type Parser = ReaderT Context (StateT Context Parser) Source #

Context-sensitive parser that remembers sorts of variables

class Parseable f g where Source #

Expressions that can be parsed

Instances
IfThenElseF :<: f => Parseable IfThenElseF f Source # 
Instance details

Defined in Data.Expression.IfThenElse

ArrayF :<: f => Parseable ArrayF f Source # 
Instance details

Defined in Data.Expression.Array

ArithmeticF :<: f => Parseable ArithmeticF f Source # 
Instance details

Defined in Data.Expression.Arithmetic

NegationF :<: f => Parseable NegationF f Source # 
Instance details

Defined in Data.Expression

DisjunctionF :<: f => Parseable DisjunctionF f Source # 
Instance details

Defined in Data.Expression

ConjunctionF :<: f => Parseable ConjunctionF f Source # 
Instance details

Defined in Data.Expression

(EqualityF :: (Sort -> Type) -> Sort -> Type) :<: f => Parseable (EqualityF :: (k -> Type) -> Sort -> Type) f Source # 
Instance details

Defined in Data.Expression.Equality

(ExistentialF v :<: f, SingI v) => Parseable (ExistentialF v :: (Sort -> Type) -> Sort -> Type) f Source # 
Instance details

Defined in Data.Expression

(UniversalF v :<: f, SingI v) => Parseable (UniversalF v :: (Sort -> Type) -> Sort -> Type) f Source # 
Instance details

Defined in Data.Expression

(VarF :: (Sort -> Type) -> Sort -> Type) :<: f => Parseable (VarF :: k -> Sort -> Type) f Source # 
Instance details

Defined in Data.Expression

(Parseable f h, Parseable g h) => Parseable (f :+: g :: k1 -> k2 -> Type) h Source # 
Instance details

Defined in Data.Expression.Parser

parse :: forall f (s :: Sort). (Parseable f f, SingI s) => Text -> Maybe (IFix f s) Source #

Tries to parse the entire input text and produce an expression in desired language and with desired sort.

parseWith :: forall f (s :: Sort). (Parseable f f, SingI s) => Context -> Text -> Maybe (IFix f s) Source #

Like parse but allows adding initial assumption about sorts of some variables.

char :: Char -> Parser Char Source #

Matches a given character.

choice :: [Parser a] -> Parser a Source #

Matches first of many choices.

decimal :: Parser Int Source #

Matches a given decimal number.

digit :: Parser Char Source #

Matches a given digit.

letter :: Parser Char Source #

Matches any character.

many1 :: Parser a -> Parser [a] Source #

Matches one or more times.

sepBy1 :: Parser a -> Parser s -> Parser [a] Source #

Matches one or more times, separated by specified separator.

signed :: Parser Int -> Parser Int Source #

Matches a signed number.

space :: Parser Char Source #

Matches space.

string :: Text -> Parser Text Source #

Matches a given string.

identifier :: Parser String Source #

Matches identifier that starts with [a-zA-Z'_#] and is followed by [a-zA-Z'_#0-9].

(<?>) :: Parser a -> String -> Parser a Source #

Labels parser.

assertSort :: String -> DynamicSort -> Parser () Source #

Asserts what sort is assigned to a variable in current context.

assumeSort :: String -> Parser DynamicSort Source #

Variable assumes sort based on current context.