@@ -54,7 +54,6 @@ module Streamly.Internal.Unicode.Char.Parser
56import Control.Applicative (Alternative(..))
56import Control.Applicative (Alternative(..))
57−import Control.Monad.Catch (MonadCatch)
58import Data.Bits (Bits, (.|.), shiftL)
57import Data.Bits (Bits, (.|.), shiftL)
59import Data.Char (ord)
58import Data.Char (ord)
60import Streamly.Internal.Data.Parser (Parser)
59import Streamly.Internal.Data.Parser (Parser)
@@ -78,7 +77,7 @@ import qualified Streamly.Internal.Data.Parser as Parser
78-- We can measure if there is a signficant difference and if so we can add such
77-- We can measure if there is a signficant difference and if so we can add such
79-- predicates to Streamly.Unicode.Parser.Latin1.
78-- predicates to Streamly.Unicode.Parser.Latin1.
81−#define CHAR_PARSER_SIG(NAME) NAME :: MonadCatch m => Parser Char m Char
80+#define CHAR_PARSER_SIG(NAME) NAME :: Monad m => Parser Char m Char
82-- XXX Need to use the predicates from Unicode.Char module/unicode-data package
81-- XXX Need to use the predicates from Unicode.Char module/unicode-data package
83#define CHAR_PARSER(NAME, PREDICATE) NAME = Parser.satisfy Char.PREDICATE
82#define CHAR_PARSER(NAME, PREDICATE) NAME = Parser.satisfy Char.PREDICATE
84#define CHAR_PARSER_DOC(PREDICATE) -- | Match any character that satisfies 'Char.PREDICATE'
83#define CHAR_PARSER_DOC(PREDICATE) -- | Match any character that satisfies 'Char.PREDICATE'
@@ -168,13 +167,13 @@ CHAR_PARSER(asciiLower,isAsciiLower)
169-- | Match a specific character.
168-- | Match a specific character.
170{-# INLINE char #-}
169{-# INLINE char #-}
171−char :: MonadCatch m => Char -> Parser Char m Char
170+char :: Monad m => Char -> Parser Char m Char
172char c = Parser.satisfy (== c)
171char c = Parser.satisfy (== c)
174-- XXX Case conversion may lead to change in number of chars
173-- XXX Case conversion may lead to change in number of chars
175-- | Match a specific character ignoring case.
174-- | Match a specific character ignoring case.
176{-# INLINE charIgnoreCase #-}
175{-# INLINE charIgnoreCase #-}
177−charIgnoreCase :: MonadCatch m => Char -> Parser Char m Char
176+charIgnoreCase :: Monad m => Char -> Parser Char m Char
178charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
177charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
180--------------------------------------------------------------------------------
179--------------------------------------------------------------------------------
@@ -182,21 +181,21 @@ charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
182--------------------------------------------------------------------------------
181--------------------------------------------------------------------------------
184-- | Match the input with the supplied string and return it if successful.
183-- | Match the input with the supplied string and return it if successful.
185−string :: MonadCatch m => String -> Parser Char m String
184+string :: Monad m => String -> Parser Char m String
186string = Parser.listEq
185string = Parser.listEq
188-- XXX Not accurate unicode case conversion
187-- XXX Not accurate unicode case conversion
189-- | Match the input with the supplied string and return it if successful.
188-- | Match the input with the supplied string and return it if successful.
190−stringIgnoreCase :: MonadCatch m => String -> Parser Char m String
189+stringIgnoreCase :: Monad m => String -> Parser Char m String
191stringIgnoreCase s =
190stringIgnoreCase s =
192 Parser.lmap Char.toLower (Parser.listEq (map Char.toLower s))
191 Parser.lmap Char.toLower (Parser.listEq (map Char.toLower s))
194-- | Drop /zero/ or more white space characters.
193-- | Drop /zero/ or more white space characters.
195−dropSpace :: MonadCatch m => Parser Char m ()
194+dropSpace :: Monad m => Parser Char m ()
196dropSpace = Parser.dropWhile Char.isSpace
195dropSpace = Parser.dropWhile Char.isSpace
198-- | Drop /one/ or more white space characters.
197-- | Drop /one/ or more white space characters.
199−dropSpace1 :: MonadCatch m => Parser Char m ()
198+dropSpace1 :: Monad m => Parser Char m ()
200dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
199dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
202--------------------------------------------------------------------------------
201--------------------------------------------------------------------------------
@@ -207,7 +206,7 @@ dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
208-- | Parse and decode an unsigned integral decimal number.
207-- | Parse and decode an unsigned integral decimal number.
209{-# INLINE decimal #-}
208{-# INLINE decimal #-}
210−decimal :: (MonadCatch m, Integral a) => Parser Char m a
209+decimal :: (Monad m, Integral a) => Parser Char m a
211decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
210decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
@@ -219,7 +218,7 @@ decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
220-- Note: This parser does not accept a leading @\"0x\"@ string.
219-- Note: This parser does not accept a leading @\"0x\"@ string.
221{-# INLINE hexadecimal #-}
220{-# INLINE hexadecimal #-}
222−hexadecimal :: (MonadCatch m, Integral a, Bits a) => Parser Char m a
221+hexadecimal :: (Monad m, Integral a, Bits a) => Parser Char m a
223hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
222hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
@@ -244,7 +243,7 @@ hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
244-- | Allow an optional leading @\'+\'@ or @\'-\'@ sign character before any
243-- | Allow an optional leading @\'+\'@ or @\'-\'@ sign character before any
245-- parser.
244-- parser.
246{-# INLINE signed #-}
245{-# INLINE signed #-}
247−signed :: (Num a, MonadCatch m) => Parser Char m a -> Parser Char m a
246+signed :: (Num a, Monad m) => Parser Char m a -> Parser Char m a
248signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
247signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
250-- | Parse a 'Double'.
249-- | Parse a 'Double'.