Copyright | (c) Paweł Nowak |
---|---|
License | MIT |
Maintainer | Paweł Nowak <pawel834@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Abstract syntax descriptions based on semi-isomorphisms.
- class (SemiIsoAlternative syn, SemiIsoMonad syn, IsSequence seq, Eq seq, Eq (Element seq)) => Syntax syn seq | syn -> seq where
- anyChar :: syn (Element seq)
- char :: Element seq -> syn ()
- notChar :: Element seq -> syn (Element seq)
- satisfy :: (Element seq -> Bool) -> syn (Element seq)
- satisfyWith :: ASemiIso' a (Element seq) -> (a -> Bool) -> syn a
- string :: seq -> syn ()
- take :: Int -> syn seq
- takeWhile :: (Element seq -> Bool) -> syn seq
- takeWhile1 :: (Element seq -> Bool) -> syn seq
- takeTill :: (Element seq -> Bool) -> syn seq
- takeTill1 :: (Element seq -> Bool) -> syn seq
- packed :: IsSequence seq => Iso' seq [Element seq]
Syntax.
class (SemiIsoAlternative syn, SemiIsoMonad syn, IsSequence seq, Eq seq, Eq (Element seq)) => Syntax syn seq | syn -> seq where Source
An abstract syntax description based on semi-isomorphisms.
This class can be implemented by both parsers and printers (and maybe more?).
The usual use is to write a polymorphic syntax description and instantiate it both as a parser and a printer. An example is available in the 'syntax-example' package.
Methods of this class try to mimic Data.Attoparsec.Text interface.
anyChar :: syn (Element seq) Source
Any character.
char :: Element seq -> syn () Source
A specific character.
notChar :: Element seq -> syn (Element seq) Source
Any character except the given one.
satisfy :: (Element seq -> Bool) -> syn (Element seq) Source
Any character satisfying a predicate.
satisfyWith :: ASemiIso' a (Element seq) -> (a -> Bool) -> syn a Source
Transforms a character using a SemiIso and filters out values not satisfying the predicate.
string :: seq -> syn () Source
A specific string.
A string of length n
.
takeWhile :: (Element seq -> Bool) -> syn seq Source
Maximal string which elements satisfy a predicate.
takeWhile1 :: (Element seq -> Bool) -> syn seq Source
Maximal non-empty string which elements satisfy a predicate.
takeTill :: (Element seq -> Bool) -> syn seq Source
Maximal string which elements do not satisfy a predicate.
takeTill1 :: (Element seq -> Bool) -> syn seq Source
Maximal non-empty string which elements do not satisfy a predicate.
Common isomorphisms.
packed :: IsSequence seq => Iso' seq [Element seq] Source
An isomorphism between a sequence and a list of its elements.