-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Abstract syntax descriptions for parsing and pretty-printing.
--
@package syntax
@version 0.2.0.0
-- | Combinators that work with any sequence type.
module Data.Syntax.Combinator
-- | Zero or more occurences of v separated by s.
sepBy :: SemiIsoAlternative f => f a -> f () -> f [a]
-- | One or more occurences of v separated by s.
sepBy1 :: SemiIsoAlternative f => f a -> f () -> f [a]
-- | One or none occurences of f.
optional :: SemiIsoAlternative f => f a -> f (Maybe a)
-- | Like optional, but specialized for ().
opt :: SemiIsoAlternative f => f () -> f ()
-- | Parser one or more occurences of f, but prints nothing.
opt_ :: SemiIsoAlternative f => f () -> f ()
-- | Abstract syntax descriptions based on semi-isomorphisms.
module Data.Syntax
-- | 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.
class (SemiIsoAlternative syn, SemiIsoMonad syn, IsSequence seq, Eq seq, Eq (Element seq)) => Syntax syn seq | syn -> seq where char c = exact c /$/ anyChar notChar c = bifiltered (/= c) /$/ anyChar satisfy p = bifiltered p /$/ anyChar satisfyWith ai p = bifiltered p . ai /$/ anyChar string s = exact s /$/ take (olength s) take n = packed /$/ sireplicate n anyChar takeWhile p = packed /$/ simany (satisfy p) takeWhile1 p = packed /$/ sisome (satisfy p) takeTill p = takeWhile (not . p) takeTill1 p = takeWhile1 (not . p)
anyChar :: Syntax syn seq => syn (Element seq)
char :: Syntax syn seq => Element seq -> syn ()
notChar :: Syntax syn seq => Element seq -> syn (Element seq)
satisfy :: Syntax syn seq => (Element seq -> Bool) -> syn (Element seq)
satisfyWith :: Syntax syn seq => ASemiIso' a (Element seq) -> (a -> Bool) -> syn a
string :: Syntax syn seq => seq -> syn ()
take :: Syntax syn seq => Int -> syn seq
takeWhile :: Syntax syn seq => (Element seq -> Bool) -> syn seq
takeWhile1 :: Syntax syn seq => (Element seq -> Bool) -> syn seq
takeTill :: Syntax syn seq => (Element seq -> Bool) -> syn seq
takeTill1 :: Syntax syn seq => (Element seq -> Bool) -> syn seq
-- | An isomorphism between a sequence and a list of its elements.
packed :: IsSequence seq => Iso' seq [Element seq]
-- | Common combinators that work with sequences of chars.
module Data.Syntax.Char
-- | Syntax constrainted to sequences of chars.
--
-- Note: methods of this class do not have default implementations (for
-- now), because their code is quite ugly and already written in most
-- parser libraries.
class (Syntax syn seq, Element seq ~ Char) => SyntaxChar syn seq
decimal :: (SyntaxChar syn seq, Integral a) => syn a
scientific :: SyntaxChar syn seq => syn Scientific
-- | A number with an optional leading + or - sign character.
signed :: (Real a, SyntaxChar syn seq) => syn a -> syn a
-- | Accepts zero or more spaces. Generates a single space.
spaces :: SyntaxChar syn seq => syn ()
-- | Accepts zero or more spaces. Generates no output.
spaces_ :: SyntaxChar syn seq => syn ()
-- | Accepts one or more spaces. Generates a single space.
spaces1 :: SyntaxChar syn seq => syn ()
-- | Accepts a single newline. Generates a newline.
endOfLine :: SyntaxChar syn seq => syn ()