mirror of
https://github.com/ilyakooo0/syntax.git
synced 2024-09-11 16:26:27 +03:00
Require SemiIsoMonad.
This commit is contained in:
parent
262260e664
commit
f187d4c3cf
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user