Require SemiIsoMonad.

This commit is contained in:
Paweł Nowak 2014-11-13 16:08:02 +01:00
parent 262260e664
commit f187d4c3cf
2 changed files with 8 additions and 1 deletions

View File

@ -74,6 +74,7 @@ packed = iso otoList fromList
--
-- Methods of this class try to mimic "Data.Attoparsec.Text" interface.
class ( SemiIsoAlternative syn
, SemiIsoMonad syn
, IsSequence seq
, Eq seq
, Eq (Element seq))

View File

@ -11,10 +11,10 @@ Stability : experimental
Common combinators that work with sequences of chars.
There are A LOT of combinators missing.
-}
module Data.Syntax.Char (
SyntaxChar(..),
signed,
spaces,
spaces_,
spaces1,
@ -44,6 +44,12 @@ class (Syntax syn seq, Element seq ~ Char) => SyntaxChar syn seq where
{-# MINIMAL decimal, scientific #-}
-- | A number with an optional leading '+' or '-' sign character.
signed :: (Num a, SyntaxChar syn seq) => syn a -> syn a
signed n = _Negative /$/ S.char '-' */ n
/|/ S.char '+' */ n
/|/ n
-- | Accepts zero or more spaces. Generates a single space.
spaces :: SyntaxChar syn seq => syn ()
spaces = constant (opoint ' ') /$/ S.takeWhile isSpace