expressions-0.1.2: 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

Minimal complete definition

parser

Instances

(:<:) Sort ArrayF f => Parseable ((Sort -> *) -> Sort -> *) ArrayF f Source # 
(:<:) Sort ArithmeticF f => Parseable ((Sort -> *) -> Sort -> *) ArithmeticF f Source # 
(:<:) Sort NegationF f => Parseable ((Sort -> *) -> Sort -> *) NegationF f Source # 
(:<:) Sort DisjunctionF f => Parseable ((Sort -> *) -> Sort -> *) DisjunctionF f Source # 
(:<:) Sort ConjunctionF f => Parseable ((Sort -> *) -> Sort -> *) ConjunctionF f Source # 
(:<:) Sort (EqualityF Sort) f => Parseable ((k -> *) -> Sort -> *) (EqualityF k) f Source # 
((:<:) Sort (ExistentialF v) f, SingI Sort v) => Parseable ((Sort -> *) -> Sort -> *) (ExistentialF v) f Source # 
((:<:) Sort (UniversalF v) f, SingI Sort v) => Parseable ((Sort -> *) -> Sort -> *) (UniversalF v) f Source # 
(:<:) Sort (VarF (Sort -> *)) f => Parseable (k -> Sort -> *) (VarF k) f Source # 
(Parseable (k1 -> k -> *) f h, Parseable (k1 -> k -> *) g h) => Parseable (k1 -> k -> *) ((:+:) k k1 f g) h Source # 

Methods

parser :: Proxy ((k :+: k1) f g) h -> Parser (DynamicallySorted g) -> Parser (DynamicallySorted g) Source #

parse :: forall f s. (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. (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.