@@ -11,10 +11,10 @@ Stability : experimental
1111
1212Common combinators that work with sequences of chars.
1313
14−There are A LOT of combinators missing.
1514-}
1615module Data.Syntax.Char (
1716 SyntaxChar(..),
17+ signed,
1818 spaces,
1919 spaces_,
2020 spaces1,
@@ -44,6 +44,12 @@ class (Syntax syn seq, Element seq ~ Char) => SyntaxChar syn seq where
4444
4545 {-# MINIMAL decimal, scientific #-}
4646
47+-- | A number with an optional leading '+' or '-' sign character.
48+signed :: (Num a, SyntaxChar syn seq) => syn a -> syn a
49+signed n = _Negative /$/ S.char '-' */ n
50+ /|/ S.char '+' */ n
51+ /|/ n
52+
4753-- | Accepts zero or more spaces. Generates a single space.
4854spaces :: SyntaxChar syn seq => syn ()
4955spaces = constant (opoint ' ') /$/ S.takeWhile isSpace