on master help sign in
Change "Parser m a b" to "Parser a m b"
239e331Adithya Kumar
benchmark/Streamly/Benchmark/Data/Array/Stream/Unboxed.hs+1−1
@@ -222,7 +222,7 @@ o_1_space_copy_toChunks_group_ungroup env =
222-------------------------------------------------------------------------------
222-------------------------------------------------------------------------------
223
223
224{-# INLINE drainWhile #-}
224{-# INLINE drainWhile #-}
225−drainWhile :: MonadCatch m => (a -> Bool) -> Parser.Parser m a ()
225+drainWhile :: MonadCatch m => (a -> Bool) -> Parser.Parser a m ()
226drainWhile p = Parser.takeWhile p Fold.drain
226drainWhile p = Parser.takeWhile p Fold.drain
227
227
228-------------------------------------------------------------------------------
228-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1
@@ -77,7 +77,7 @@ eqBy :: Int -> Stream IO Int -> IO ()
77eqBy len = Stream.parseD (PR.eqBy (==) (D.enumerateFromToIntegral 1 len))
77eqBy len = Stream.parseD (PR.eqBy (==) (D.enumerateFromToIntegral 1 len))
78
78
79{-# INLINE drainWhile #-}
79{-# INLINE drainWhile #-}
80−drainWhile :: MonadThrow m => (a -> Bool) -> PR.Parser m a ()
80+drainWhile :: MonadThrow m => (a -> Bool) -> PR.Parser a m ()
81drainWhile p = PR.takeWhile p Fold.drain
81drainWhile p = PR.takeWhile p Fold.drain
82
82
83{-# INLINE takeStartBy #-}
83{-# INLINE takeStartBy #-}
benchmark/Streamly/Benchmark/Data/Parser/ParserK.hs+2−2
@@ -65,11 +65,11 @@ benchIOSink value name f =
65#endif
65#endif
66
66
67{-# INLINE satisfy #-}
67{-# INLINE satisfy #-}
68−satisfy :: Monad m => (a -> Bool) -> PR.Parser m a a
68+satisfy :: Monad m => (a -> Bool) -> PR.Parser a m a
69satisfy = PRD.toParserK . PRD.satisfy
69satisfy = PRD.toParserK . PRD.satisfy
70
70
71{-# INLINE takeWhile #-}
71{-# INLINE takeWhile #-}
72−takeWhile :: Monad m => (a -> Bool) -> PR.Parser m a ()
72+takeWhile :: Monad m => (a -> Bool) -> PR.Parser a m ()
73takeWhile p = PRD.toParserK $ PRD.takeWhile p FL.drain
73takeWhile p = PRD.toParserK $ PRD.takeWhile p FL.drain
74
74
75{-# INLINE takeWhileK #-}
75{-# INLINE takeWhileK #-}
core/src/Streamly/Internal/Data/Array/Unboxed/Fold.hs+3−3
@@ -88,7 +88,7 @@ import Prelude hiding (concatMap, take)
88--
88--
89-- /Pre-release/
89-- /Pre-release/
90--
90--
91−newtype ArrayFold m a b = ArrayFold (ParserD.Parser m (Array a) b)
91+newtype ArrayFold m a b = ArrayFold (ParserD.Parser (Array a) m b)
92
92
93-------------------------------------------------------------------------------
93-------------------------------------------------------------------------------
94-- Constructing array stream folds from element folds and parsers
94-- Constructing array stream folds from element folds and parsers
@@ -145,7 +145,7 @@ fromParserD :: forall m a b. (MonadIO m) =>
145#else
145#else
146fromParserD :: forall m a b. (MonadIO m, Unbox a) =>
146fromParserD :: forall m a b. (MonadIO m, Unbox a) =>
147#endif
147#endif
148− ParserD.Parser m a b -> ArrayFold m a b
148+ ParserD.Parser a m b -> ArrayFold m a b
149fromParserD (ParserD.Parser step1 initial1 extract1) =
149fromParserD (ParserD.Parser step1 initial1 extract1) =
150 ArrayFold (ParserD.Parser step initial1 extract1)
150 ArrayFold (ParserD.Parser step initial1 extract1)
151
151
@@ -191,7 +191,7 @@ fromParser :: forall m a b. (MonadThrow m, MonadIO m) =>
191#else
191#else
192fromParser :: forall m a b. (MonadThrow m, MonadIO m, Unbox a) =>
192fromParser :: forall m a b. (MonadThrow m, MonadIO m, Unbox a) =>
193#endif
193#endif
194− Parser.Parser m a b -> ArrayFold m a b
194+ Parser.Parser a m b -> ArrayFold m a b
195fromParser = fromParserD . ParserD.fromParserK
195fromParser = fromParserD . ParserD.fromParserK
196
196
197-- | Adapt an array stream fold.
197-- | Adapt an array stream fold.
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Stream.hs+1−1
@@ -205,7 +205,7 @@ compact n = Stream.fromStreamD . packArraysChunksOf n . Stream.toStreamD
205{-# INLINE_NORMAL compactLEParserD #-}
205{-# INLINE_NORMAL compactLEParserD #-}
206compactLEParserD ::
206compactLEParserD ::
207 forall m a. (MonadThrow m, MonadIO m, Unbox a)
207 forall m a. (MonadThrow m, MonadIO m, Unbox a)
208− => Int -> ParserD.Parser m (Array a) (Array a)
208+ => Int -> ParserD.Parser (Array a) m (Array a)
209compactLEParserD n = ParserD.Parser step initial extract
209compactLEParserD n = ParserD.Parser step initial extract
210
210
211 where
211 where
core/src/Streamly/Internal/Data/Array/Unboxed/Stream.hs+6−6
@@ -554,7 +554,7 @@ newtype List a = List {getList :: [a]}
554{-# INLINE_NORMAL parseBreakD #-}
554{-# INLINE_NORMAL parseBreakD #-}
555parseBreakD ::
555parseBreakD ::
556 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
556 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
557− => PRD.Parser m a b
557+ => PRD.Parser a m b
558 -> D.Stream m (Array.Array a)
558 -> D.Stream m (Array.Array a)
559 -> m (b, D.Stream m (Array.Array a))
559 -> m (b, D.Stream m (Array.Array a))
560parseBreakD
560parseBreakD
@@ -635,7 +635,7 @@ parseBreakD
635{-# INLINE_NORMAL parseBreakK #-}
635{-# INLINE_NORMAL parseBreakK #-}
636parseBreakK ::
636parseBreakK ::
637 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
637 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
638− => PRD.Parser m a b
638+ => PRD.Parser a m b
639 -> K.Stream m (Array.Array a)
639 -> K.Stream m (Array.Array a)
640 -> m (b, K.Stream m (Array.Array a))
640 -> m (b, K.Stream m (Array.Array a))
641parseBreakK (PRD.Parser pstep initial extract) stream = do
641parseBreakK (PRD.Parser pstep initial extract) stream = do
@@ -770,7 +770,7 @@ parseBreakK (PRD.Parser pstep initial extract) stream = do
770{-# INLINE_NORMAL parseBreak #-}
770{-# INLINE_NORMAL parseBreak #-}
771parseBreak ::
771parseBreak ::
772 (MonadIO m, MonadThrow m, Unbox a)
772 (MonadIO m, MonadThrow m, Unbox a)
773− => PR.Parser m a b
773+ => PR.Parser a m b
774 -> Stream m (A.Array a)
774 -> Stream m (A.Array a)
775 -> m (b, Stream m (A.Array a))
775 -> m (b, Stream m (A.Array a))
776{-
776{-
@@ -786,7 +786,7 @@ parseBreak p =
786-- Elimination - Running Array Folds and parsers
786-- Elimination - Running Array Folds and parsers
787-------------------------------------------------------------------------------
787-------------------------------------------------------------------------------
788
788
789−-- | Note that this is not the same as using a @Parser m (Array a) b@ with the
789+-- | Note that this is not the same as using a @Parser (Array a) m b@ with the
790-- regular "Streamly.Internal.Data.IsStream.parse" function. The regular parse
790-- regular "Streamly.Internal.Data.IsStream.parse" function. The regular parse
791-- would consume the input arrays as single unit. This parser parses in the way
791-- would consume the input arrays as single unit. This parser parses in the way
792-- as described in the ArrayFold module. The input arrays are treated as @n@
792-- as described in the ArrayFold module. The input arrays are treated as @n@
@@ -796,7 +796,7 @@ parseBreak p =
796{-# INLINE_NORMAL runArrayParserDBreak #-}
796{-# INLINE_NORMAL runArrayParserDBreak #-}
797runArrayParserDBreak ::
797runArrayParserDBreak ::
798 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
798 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
799− => PRD.Parser m (Array a) b
799+ => PRD.Parser (Array a) m b
800 -> D.Stream m (Array.Array a)
800 -> D.Stream m (Array.Array a)
801 -> m (b, D.Stream m (Array.Array a))
801 -> m (b, D.Stream m (Array.Array a))
802runArrayParserDBreak
802runArrayParserDBreak
@@ -925,7 +925,7 @@ runArrayParserDBreak
925{-# INLINE parseArr #-}
925{-# INLINE parseArr #-}
926parseArr ::
926parseArr ::
927 (MonadIO m, MonadThrow m, Unbox a)
927 (MonadIO m, MonadThrow m, Unbox a)
928− => ASF.Parser m a b
928+ => ASF.Parser a m b
929 -> Stream m (A.Array a)
929 -> Stream m (A.Array a)
930 -> m (b, Stream m (A.Array a))
930 -> m (b, Stream m (A.Array a))
931parseArr p s = fmap fromStreamD <$> parseBreakD p (toStreamD s)
931parseArr p s = fmap fromStreamD <$> parseBreakD p (toStreamD s)
core/src/Streamly/Internal/Data/Binary/Decode.hs+18−18
@@ -48,7 +48,7 @@ import qualified Streamly.Internal.Data.Parser.ParserD as PRD
48-- /Pre-release/
48-- /Pre-release/
49--
49--
50{-# INLINE unit #-}
50{-# INLINE unit #-}
51−unit :: Monad m => Parser m Word8 ()
51+unit :: Monad m => Parser Word8 m ()
52unit = eqWord8 0 *> PR.fromPure ()
52unit = eqWord8 0 *> PR.fromPure ()
53
53
54{-# INLINE word8ToBool #-}
54{-# INLINE word8ToBool #-}
@@ -67,7 +67,7 @@ word8ToBool w = Left ("Invalid Bool encoding " ++ Prelude.show w)
67-- /Pre-release/
67-- /Pre-release/
68--
68--
69{-# INLINE bool #-}
69{-# INLINE bool #-}
70−bool :: Monad m => Parser m Word8 Bool
70+bool :: Monad m => Parser Word8 m Bool
71bool = PR.either word8ToBool
71bool = PR.either word8ToBool
72
72
73{-# INLINE word8ToOrdering #-}
73{-# INLINE word8ToOrdering #-}
@@ -88,7 +88,7 @@ word8ToOrdering w = Left ("Invalid Ordering encoding " ++ Prelude.show w)
88-- /Pre-release/
88-- /Pre-release/
89--
89--
90{-# INLINE ordering #-}
90{-# INLINE ordering #-}
91−ordering :: Monad m => Parser m Word8 Ordering
91+ordering :: Monad m => Parser Word8 m Ordering
92ordering = PR.either word8ToOrdering
92ordering = PR.either word8ToOrdering
93
93
94-- XXX should go in a Word8 parser module?
94-- XXX should go in a Word8 parser module?
@@ -97,7 +97,7 @@ ordering = PR.either word8ToOrdering
97-- /Pre-release/
97-- /Pre-release/
98--
98--
99{-# INLINE eqWord8 #-}
99{-# INLINE eqWord8 #-}
100−eqWord8 :: Monad m => Word8 -> Parser m Word8 Word8
100+eqWord8 :: Monad m => Word8 -> Parser Word8 m Word8
101eqWord8 b = PR.satisfy (== b)
101eqWord8 b = PR.satisfy (== b)
102
102
103-- | Accept any byte.
103-- | Accept any byte.
@@ -105,12 +105,12 @@ eqWord8 b = PR.satisfy (== b)
105-- /Pre-release/
105-- /Pre-release/
106--
106--
107{-# INLINE word8 #-}
107{-# INLINE word8 #-}
108−word8 :: Monad m => Parser m Word8 Word8
108+word8 :: Monad m => Parser Word8 m Word8
109word8 = PR.satisfy (const True)
109word8 = PR.satisfy (const True)
110
110
111-- | Big endian (MSB first) Word16
111-- | Big endian (MSB first) Word16
112{-# INLINE word16beD #-}
112{-# INLINE word16beD #-}
113−word16beD :: Monad m => PRD.Parser m Word8 Word16
113+word16beD :: Monad m => PRD.Parser Word8 m Word16
114word16beD = PRD.Parser step initial extract
114word16beD = PRD.Parser step initial extract
115
115
116 where
116 where
@@ -132,12 +132,12 @@ word16beD = PRD.Parser step initial extract
132-- /Pre-release/
132-- /Pre-release/
133--
133--
134{-# INLINE word16be #-}
134{-# INLINE word16be #-}
135−word16be :: Monad m => Parser m Word8 Word16
135+word16be :: Monad m => Parser Word8 m Word16
136word16be = PRD.toParserK word16beD
136word16be = PRD.toParserK word16beD
137
137
138-- | Little endian (LSB first) Word16
138-- | Little endian (LSB first) Word16
139{-# INLINE word16leD #-}
139{-# INLINE word16leD #-}
140−word16leD :: Monad m => PRD.Parser m Word8 Word16
140+word16leD :: Monad m => PRD.Parser Word8 m Word16
141word16leD = PRD.Parser step initial extract
141word16leD = PRD.Parser step initial extract
142
142
143 where
143 where
@@ -157,12 +157,12 @@ word16leD = PRD.Parser step initial extract
157-- /Pre-release/
157-- /Pre-release/
158--
158--
159{-# INLINE word16le #-}
159{-# INLINE word16le #-}
160−word16le :: Monad m => Parser m Word8 Word16
160+word16le :: Monad m => Parser Word8 m Word16
161word16le = PRD.toParserK word16leD
161word16le = PRD.toParserK word16leD
162
162
163-- | Big endian (MSB first) Word32
163-- | Big endian (MSB first) Word32
164{-# INLINE word32beD #-}
164{-# INLINE word32beD #-}
165−word32beD :: Monad m => PRD.Parser m Word8 Word32
165+word32beD :: Monad m => PRD.Parser Word8 m Word32
166word32beD = PRD.Parser step initial extract
166word32beD = PRD.Parser step initial extract
167
167
168 where
168 where
@@ -184,12 +184,12 @@ word32beD = PRD.Parser step initial extract
184-- /Pre-release/
184-- /Pre-release/
185--
185--
186{-# INLINE word32be #-}
186{-# INLINE word32be #-}
187−word32be :: Monad m => Parser m Word8 Word32
187+word32be :: Monad m => Parser Word8 m Word32
188word32be = PRD.toParserK word32beD
188word32be = PRD.toParserK word32beD
189
189
190-- | Little endian (LSB first) Word32
190-- | Little endian (LSB first) Word32
191{-# INLINE word32leD #-}
191{-# INLINE word32leD #-}
192−word32leD :: Monad m => PRD.Parser m Word8 Word32
192+word32leD :: Monad m => PRD.Parser Word8 m Word32
193word32leD = PRD.Parser step initial extract
193word32leD = PRD.Parser step initial extract
194
194
195 where
195 where
@@ -210,12 +210,12 @@ word32leD = PRD.Parser step initial extract
210-- /Pre-release/
210-- /Pre-release/
211--
211--
212{-# INLINE word32le #-}
212{-# INLINE word32le #-}
213−word32le :: Monad m => Parser m Word8 Word32
213+word32le :: Monad m => Parser Word8 m Word32
214word32le = PRD.toParserK word32leD
214word32le = PRD.toParserK word32leD
215
215
216-- | Big endian (MSB first) Word64
216-- | Big endian (MSB first) Word64
217{-# INLINE word64beD #-}
217{-# INLINE word64beD #-}
218−word64beD :: Monad m => PRD.Parser m Word8 Word64
218+word64beD :: Monad m => PRD.Parser Word8 m Word64
219word64beD = PRD.Parser step initial extract
219word64beD = PRD.Parser step initial extract
220
220
221 where
221 where
@@ -237,12 +237,12 @@ word64beD = PRD.Parser step initial extract
237-- /Pre-release/
237-- /Pre-release/
238--
238--
239{-# INLINE word64be #-}
239{-# INLINE word64be #-}
240−word64be :: Monad m => Parser m Word8 Word64
240+word64be :: Monad m => Parser Word8 m Word64
241word64be = PRD.toParserK word64beD
241word64be = PRD.toParserK word64beD
242
242
243-- | Little endian (LSB first) Word64
243-- | Little endian (LSB first) Word64
244{-# INLINE word64leD #-}
244{-# INLINE word64leD #-}
245−word64leD :: Monad m => PRD.Parser m Word8 Word64
245+word64leD :: Monad m => PRD.Parser Word8 m Word64
246word64leD = PRD.Parser step initial extract
246word64leD = PRD.Parser step initial extract
247
247
248 where
248 where
@@ -263,7 +263,7 @@ word64leD = PRD.Parser step initial extract
263-- /Pre-release/
263-- /Pre-release/
264--
264--
265{-# INLINE word64le #-}
265{-# INLINE word64le #-}
266−word64le :: Monad m => Parser m Word8 Word64
266+word64le :: Monad m => Parser Word8 m Word64
267word64le = PRD.toParserK word64leD
267word64le = PRD.toParserK word64leD
268
268
269-------------------------------------------------------------------------------
269-------------------------------------------------------------------------------
@@ -275,6 +275,6 @@ word64le = PRD.toParserK word64leD
275-- /Pre-release/
275-- /Pre-release/
276--
276--
277{-# INLINE word64host #-}
277{-# INLINE word64host #-}
278−word64host :: MonadIO m => Parser m Word8 Word64
278+word64host :: MonadIO m => Parser Word8 m Word64
279word64host =
279word64host =
280 fmap (A.unsafeIndex 0 . A.castUnsafe) $ PR.takeEQ 8 (A.writeN 8)
280 fmap (A.unsafeIndex 0 . A.castUnsafe) $ PR.takeEQ 8 (A.writeN 8)
core/src/Streamly/Internal/Data/Fold/Type.hs+1−1
@@ -239,7 +239,7 @@
239-- | Continue Int s -- no result and how much to backtrack
239-- | Continue Int s -- no result and how much to backtrack
240-- | Error String -- error
240-- | Error String -- error
241--
241--
242−-- data Parser m a b =
242+-- data Parser a m b =
243-- forall s. Fold
243-- forall s. Fold
244-- (s -> a -> m (Step s b)) -- step
244-- (s -> a -> m (Step s b)) -- step
245-- (m (Step s b)) -- initial
245-- (m (Step s b)) -- initial
core/src/Streamly/Internal/Data/Parser.hs+83−83
@@ -290,7 +290,7 @@ import Prelude hiding
290-- /Pre-release/
290-- /Pre-release/
291--
291--
292{-# INLINE toFold #-}
292{-# INLINE toFold #-}
293−toFold :: Monad m => Parser m a b -> Fold m a b
293+toFold :: Monad m => Parser a m b -> Fold m a b
294toFold p = D.toFold $ D.fromParserK p
294toFold p = D.toFold $ D.fromParserK p
295
295
296-------------------------------------------------------------------------------
296-------------------------------------------------------------------------------
@@ -300,7 +300,7 @@ toFold p = D.toFold $ D.fromParserK p
300-- | Make a 'Parser' from a 'Fold'.
300-- | Make a 'Parser' from a 'Fold'.
301--
301--
302{-# INLINE fromFold #-}
302{-# INLINE fromFold #-}
303−fromFold :: Monad m => Fold m a b -> Parser m a b
303+fromFold :: Monad m => Fold m a b -> Parser a m b
304fromFold = D.toParserK . D.fromFold
304fromFold = D.toParserK . D.fromFold
305
305
306-- | Convert a Maybe returning fold to an error returning parser. The first
306-- | Convert a Maybe returning fold to an error returning parser. The first
@@ -310,7 +310,7 @@ fromFold = D.toParserK . D.fromFold
310-- /Pre-release/
310-- /Pre-release/
311--
311--
312{-# INLINE fromFoldMaybe #-}
312{-# INLINE fromFoldMaybe #-}
313−fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser m a b
313+fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser a m b
314fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
314fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
315
315
316-------------------------------------------------------------------------------
316-------------------------------------------------------------------------------
@@ -322,7 +322,7 @@ fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
322-- | A parser that always yields a pure value without consuming any input.
322-- | A parser that always yields a pure value without consuming any input.
323--
323--
324{-# INLINE [3] fromPure #-}
324{-# INLINE [3] fromPure #-}
325−fromPure :: Monad m => b -> Parser m a b
325+fromPure :: Monad m => b -> Parser a m b
326fromPure = D.toParserK . D.fromPure
326fromPure = D.toParserK . D.fromPure
327{-# RULES "fromPure fallback to CPS" [2]
327{-# RULES "fromPure fallback to CPS" [2]
328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
@@ -333,7 +333,7 @@ fromPure = D.toParserK . D.fromPure
333-- consuming any input.
333-- consuming any input.
334--
334--
335{-# INLINE fromEffect #-}
335{-# INLINE fromEffect #-}
336−fromEffect :: Monad m => m b -> Parser m a b
336+fromEffect :: Monad m => m b -> Parser a m b
337fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
337fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
338
338
339-- This is the dual of "nil".
339-- This is the dual of "nil".
@@ -342,7 +342,7 @@ fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
342-- any input.
342-- any input.
343--
343--
344{-# INLINE [3] die #-}
344{-# INLINE [3] die #-}
345−die :: Monad m => String -> Parser m a b
345+die :: Monad m => String -> Parser a m b
346die = D.toParserK . D.die
346die = D.toParserK . D.die
347{-# RULES "die fallback to CPS" [2]
347{-# RULES "die fallback to CPS" [2]
348 forall a. D.toParserK (D.die a) = K.die a #-}
348 forall a. D.toParserK (D.die a) = K.die a #-}
@@ -355,7 +355,7 @@ die = D.toParserK . D.die
355-- /Pre-release/
355-- /Pre-release/
356--
356--
357{-# INLINE dieM #-}
357{-# INLINE dieM #-}
358−dieM :: Monad m => m String -> Parser m a b
358+dieM :: Monad m => m String -> Parser a m b
359dieM = D.toParserK . D.dieM
359dieM = D.toParserK . D.dieM
360
360
361-------------------------------------------------------------------------------
361-------------------------------------------------------------------------------
@@ -370,20 +370,20 @@ dieM = D.toParserK . D.dieM
370-- > lmap = Parser.lmapM return
370-- > lmap = Parser.lmapM return
371--
371--
372{-# INLINE lmap #-}
372{-# INLINE lmap #-}
373−lmap :: Monad m => (a -> b) -> Parser m b r -> Parser m a r
373+lmap :: Monad m => (a -> b) -> Parser b m r -> Parser a m r
374lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
374lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
375
375
376-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
376-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
377--
377--
378{-# INLINE lmapM #-}
378{-# INLINE lmapM #-}
379−lmapM :: Monad m => (a -> m b) -> Parser m b r -> Parser m a r
379+lmapM :: Monad m => (a -> m b) -> Parser b m r -> Parser a m r
380lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
380lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
381
381
382-- | @rmapM f parser@ maps the monadic function @f@ on the output of the parser.
382-- | @rmapM f parser@ maps the monadic function @f@ on the output of the parser.
383--
383--
384-- >>> rmap = fmap
384-- >>> rmap = fmap
385{-# INLINE rmapM #-}
385{-# INLINE rmapM #-}
386−rmapM :: Monad m => (b -> m c) -> Parser m a b -> Parser m a c
386+rmapM :: Monad m => (b -> m c) -> Parser a m b -> Parser a m c
387rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
387rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
388
388
389-- | Include only those elements that pass a predicate.
389-- | Include only those elements that pass a predicate.
@@ -392,7 +392,7 @@ rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
392-- 40
392-- 40
393--
393--
394{-# INLINE filter #-}
394{-# INLINE filter #-}
395−filter :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
395+filter :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
397
397
398-------------------------------------------------------------------------------
398-------------------------------------------------------------------------------
@@ -410,7 +410,7 @@ filter f p = D.toParserK $ D.filter f $ D.fromParserK p
410-- @
410-- @
411--
411--
412{-# INLINE peek #-}
412{-# INLINE peek #-}
413−peek :: Monad m => Parser m a a
413+peek :: Monad m => Parser a m a
414peek = D.toParserK D.peek
414peek = D.toParserK D.peek
415
415
416-- | Succeeds if we are at the end of input, fails otherwise.
416-- | Succeeds if we are at the end of input, fails otherwise.
@@ -419,7 +419,7 @@ peek = D.toParserK D.peek
419-- (1,())
419-- (1,())
420--
420--
421{-# INLINE eof #-}
421{-# INLINE eof #-}
422−eof :: Monad m => Parser m a ()
422+eof :: Monad m => Parser a m ()
423eof = D.toParserK D.eof
423eof = D.toParserK D.eof
424
424
425-- | Returns the next element if it passes the predicate, fails otherwise.
425-- | Returns the next element if it passes the predicate, fails otherwise.
@@ -431,7 +431,7 @@ eof = D.toParserK D.eof
431-- >>> satisfy f = Parser.maybe (toMaybe f)
431-- >>> satisfy f = Parser.maybe (toMaybe f)
432--
432--
433{-# INLINE satisfy #-}
433{-# INLINE satisfy #-}
434−satisfy :: Monad m => (a -> Bool) -> Parser m a a
434+satisfy :: Monad m => (a -> Bool) -> Parser a m a
435satisfy = D.toParserK . D.satisfy
435satisfy = D.toParserK . D.satisfy
436
436
437-- | Consume one element from the head of the stream. Fails if it encounters
437-- | Consume one element from the head of the stream. Fails if it encounters
@@ -440,7 +440,7 @@ satisfy = D.toParserK . D.satisfy
440-- >>> one = Parser.satisfy $ const True
440-- >>> one = Parser.satisfy $ const True
441--
441--
442{-# INLINE one #-}
442{-# INLINE one #-}
443−one :: Monad m => Parser m a a
443+one :: Monad m => Parser a m a
444one = satisfy $ const True
444one = satisfy $ const True
445
445
446-- Alternate names: "only", "onlyThis".
446-- Alternate names: "only", "onlyThis".
@@ -450,7 +450,7 @@ one = satisfy $ const True
450-- >>> oneEq x = Parser.satisfy (== x)
450-- >>> oneEq x = Parser.satisfy (== x)
451--
451--
452{-# INLINE oneEq #-}
452{-# INLINE oneEq #-}
453−oneEq :: (Monad m, Eq a) => a -> Parser m a a
453+oneEq :: (Monad m, Eq a) => a -> Parser a m a
454oneEq x = satisfy (== x)
454oneEq x = satisfy (== x)
455
455
456-- Alternate names: "exclude", "notThis".
456-- Alternate names: "exclude", "notThis".
@@ -460,7 +460,7 @@ oneEq x = satisfy (== x)
460-- >>> oneNotEq x = Parser.satisfy (/= x)
460-- >>> oneNotEq x = Parser.satisfy (/= x)
461--
461--
462{-# INLINE oneNotEq #-}
462{-# INLINE oneNotEq #-}
463−oneNotEq :: (Monad m, Eq a) => a -> Parser m a a
463+oneNotEq :: (Monad m, Eq a) => a -> Parser a m a
464oneNotEq x = satisfy (/= x)
464oneNotEq x = satisfy (/= x)
465
465
466-- | Match any one of the elements in the supplied list.
466-- | Match any one of the elements in the supplied list.
@@ -484,7 +484,7 @@ oneNotEq x = satisfy (/= x)
484-- search.
484-- search.
485--
485--
486{-# INLINE oneOf #-}
486{-# INLINE oneOf #-}
487−oneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser m a a
487+oneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser a m a
488oneOf xs = satisfy (`Foldable.elem` xs)
488oneOf xs = satisfy (`Foldable.elem` xs)
489
489
490-- | See performance notes in 'oneOf'.
490-- | See performance notes in 'oneOf'.
@@ -492,7 +492,7 @@ oneOf xs = satisfy (`Foldable.elem` xs)
492-- >>> noneOf xs = Parser.satisfy (`Foldable.notElem` xs)
492-- >>> noneOf xs = Parser.satisfy (`Foldable.notElem` xs)
493--
493--
494{-# INLINE noneOf #-}
494{-# INLINE noneOf #-}
495−noneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser m a a
495+noneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser a m a
496noneOf xs = satisfy (`Foldable.notElem` xs)
496noneOf xs = satisfy (`Foldable.notElem` xs)
497
497
498-- | Return the next element of the input. Returns 'Nothing'
498-- | Return the next element of the input. Returns 'Nothing'
@@ -502,7 +502,7 @@ noneOf xs = satisfy (`Foldable.notElem` xs)
502--
502--
503{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
503{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
504{-# INLINE next #-}
504{-# INLINE next #-}
505−next :: Monad m => Parser m a (Maybe a)
505+next :: Monad m => Parser a m (Maybe a)
506next = D.toParserK D.next
506next = D.toParserK D.next
507
507
508-- | Map a 'Maybe' returning function on the next element in the stream. The
508-- | Map a 'Maybe' returning function on the next element in the stream. The
@@ -517,7 +517,7 @@ next = D.toParserK D.next
517-- /Pre-release/
517-- /Pre-release/
518--
518--
519{-# INLINE maybe #-}
519{-# INLINE maybe #-}
520−maybe :: Monad m => (a -> Maybe b) -> Parser m a b
520+maybe :: Monad m => (a -> Maybe b) -> Parser a m b
521maybe = D.toParserK . D.maybe
521maybe = D.toParserK . D.maybe
522
522
523-- | Map an 'Either' returning function on the next element in the stream. If
523-- | Map an 'Either' returning function on the next element in the stream. If
@@ -527,7 +527,7 @@ maybe = D.toParserK . D.maybe
527-- /Pre-release/
527-- /Pre-release/
528--
528--
529{-# INLINE either #-}
529{-# INLINE either #-}
530−either :: Monad m => (a -> Either String b) -> Parser m a b
530+either :: Monad m => (a -> Either String b) -> Parser a m b
531either = D.toParserK . D.either
531either = D.toParserK . D.either
532
532
533-------------------------------------------------------------------------------
533-------------------------------------------------------------------------------
@@ -576,7 +576,7 @@ either = D.toParserK . D.either
576--
576--
577{-# INLINE takeBetween #-}
577{-# INLINE takeBetween #-}
578takeBetween :: Monad m =>
578takeBetween :: Monad m =>
579− Int -> Int -> Fold m a b -> Parser m a b
579+ Int -> Int -> Fold m a b -> Parser a m b
580takeBetween m n = D.toParserK . D.takeBetween m n
580takeBetween m n = D.toParserK . D.takeBetween m n
581
581
582-- | Stops after taking exactly @n@ input elements.
582-- | Stops after taking exactly @n@ input elements.
@@ -589,7 +589,7 @@ takeBetween m n = D.toParserK . D.takeBetween m n
589-- *** Exception: ParseError "takeEQ: Expecting exactly 4 elements, input terminated on 3"
589-- *** Exception: ParseError "takeEQ: Expecting exactly 4 elements, input terminated on 3"
590--
590--
591{-# INLINE takeEQ #-}
591{-# INLINE takeEQ #-}
592−takeEQ :: Monad m => Int -> Fold m a b -> Parser m a b
592+takeEQ :: Monad m => Int -> Fold m a b -> Parser a m b
593takeEQ n = D.toParserK . D.takeEQ n
593takeEQ n = D.toParserK . D.takeEQ n
594
594
595-- | Take at least @n@ input elements, but can collect more.
595-- | Take at least @n@ input elements, but can collect more.
@@ -607,7 +607,7 @@ takeEQ n = D.toParserK . D.takeEQ n
607-- /Pre-release/
607-- /Pre-release/
608--
608--
609{-# INLINE takeGE #-}
609{-# INLINE takeGE #-}
610−takeGE :: Monad m => Int -> Fold m a b -> Parser m a b
610+takeGE :: Monad m => Int -> Fold m a b -> Parser a m b
611takeGE n = D.toParserK . D.takeGE n
611takeGE n = D.toParserK . D.takeGE n
612
612
613-------------------------------------------------------------------------------
613-------------------------------------------------------------------------------
@@ -634,7 +634,7 @@ takeGE n = D.toParserK . D.takeGE n
634-- /Pre-release/
634-- /Pre-release/
635--
635--
636{-# INLINE takeWhileP #-}
636{-# INLINE takeWhileP #-}
637−takeWhileP :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
637+takeWhileP :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
638takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
638takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
639
639
640-- | Collect stream elements until an element fails the predicate. The element
640-- | Collect stream elements until an element fails the predicate. The element
@@ -655,7 +655,7 @@ takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
655-- @
655-- @
656--
656--
657{-# INLINE takeWhile #-}
657{-# INLINE takeWhile #-}
658−takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
658+takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
659takeWhile cond = D.toParserK . D.takeWhile cond
659takeWhile cond = D.toParserK . D.takeWhile cond
660-- takeWhile cond f = takeWhileP cond (fromFold f)
660-- takeWhile cond f = takeWhileP cond (fromFold f)
661
661
@@ -664,7 +664,7 @@ takeWhile cond = D.toParserK . D.takeWhile cond
664-- >>> takeWhile1 cond p = Parser.takeWhileP cond (Parser.takeBetween 1 maxBound p)
664-- >>> takeWhile1 cond p = Parser.takeWhileP cond (Parser.takeBetween 1 maxBound p)
665--
665--
666{-# INLINE takeWhile1 #-}
666{-# INLINE takeWhile1 #-}
667−takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
667+takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
668takeWhile1 cond = D.toParserK . D.takeWhile1 cond
668takeWhile1 cond = D.toParserK . D.takeWhile1 cond
669-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
669-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
670
670
@@ -676,7 +676,7 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
676-- >>> dropWhile p = Parser.takeWhile p Fold.drain
676-- >>> dropWhile p = Parser.takeWhile p Fold.drain
677--
677--
678{-# INLINE dropWhile #-}
678{-# INLINE dropWhile #-}
679−dropWhile :: Monad m => (a -> Bool) -> Parser m a ()
679+dropWhile :: Monad m => (a -> Bool) -> Parser a m ()
680dropWhile p = takeWhile p FL.drain
680dropWhile p = takeWhile p FL.drain
681
681
682-------------------------------------------------------------------------------
682-------------------------------------------------------------------------------
@@ -690,7 +690,7 @@ takeFramedByGeneric :: Monad m =>
690 -> Maybe (a -> Bool)
690 -> Maybe (a -> Bool)
691 -> Maybe (a -> Bool)
691 -> Maybe (a -> Bool)
692 -> Fold m a b
692 -> Fold m a b
693− -> Parser m a b
693+ -> Parser a m b
694takeFramedByGeneric esc begin end f =
694takeFramedByGeneric esc begin end f =
695 D.toParserK $ D.takeFramedByGeneric esc begin end f
695 D.toParserK $ D.takeFramedByGeneric esc begin end f
696
696
@@ -712,7 +712,7 @@ takeFramedByGeneric esc begin end f =
712-- /Pre-release/
712-- /Pre-release/
713--
713--
714{-# INLINE takeEndBy #-}
714{-# INLINE takeEndBy #-}
715−takeEndBy :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
715+takeEndBy :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
716takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
716takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
717-- takeEndBy = takeEndByEsc (const False)
717-- takeEndBy = takeEndByEsc (const False)
718
718
@@ -723,7 +723,7 @@ takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
723-- /Pre-release/
723-- /Pre-release/
724--
724--
725{-# INLINE takeEndBy_ #-}
725{-# INLINE takeEndBy_ #-}
726−takeEndBy_ :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
726+takeEndBy_ :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
727takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
727takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
728{-
728{-
729takeEndBy_ isEnd p =
729takeEndBy_ isEnd p =
@@ -736,7 +736,7 @@ takeEndBy_ isEnd p =
736-- /Unimplemented/
736-- /Unimplemented/
737{-# INLINE takeEitherSepBy #-}
737{-# INLINE takeEitherSepBy #-}
738takeEitherSepBy :: -- Monad m =>
738takeEitherSepBy :: -- Monad m =>
739− (a -> Bool) -> Fold m (Either a b) c -> Parser m a c
739+ (a -> Bool) -> Fold m (Either a b) c -> Parser a m c
740takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
740takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
741
741
742-- | Parse a token that starts with an element chosen by the predicate. The
742-- | Parse a token that starts with an element chosen by the predicate. The
@@ -764,7 +764,7 @@ takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
764-- /Pre-release/
764-- /Pre-release/
765--
765--
766{-# INLINE takeStartBy #-}
766{-# INLINE takeStartBy #-}
767−takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
767+takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
768takeStartBy cond = D.toParserK . D.takeStartBy cond
768takeStartBy cond = D.toParserK . D.takeStartBy cond
769
769
770-- | Like 'takeStartBy' but drops the separator.
770-- | Like 'takeStartBy' but drops the separator.
@@ -772,7 +772,7 @@ takeStartBy cond = D.toParserK . D.takeStartBy cond
772-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
772-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
773--
773--
774{-# INLINE takeStartBy_ #-}
774{-# INLINE takeStartBy_ #-}
775−takeStartBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
775+takeStartBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
776takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
776takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
777
777
778-------------------------------------------------------------------------------
778-------------------------------------------------------------------------------
@@ -786,7 +786,7 @@ takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
786-- /pre-release/
786-- /pre-release/
787{-# INLINE takeEndByEsc #-}
787{-# INLINE takeEndByEsc #-}
788takeEndByEsc :: Monad m =>
788takeEndByEsc :: Monad m =>
789− (a -> Bool) -> (a -> Bool) -> Parser m a b -> Parser m a b
789+ (a -> Bool) -> (a -> Bool) -> Parser a m b -> Parser a m b
790takeEndByEsc isEsc isEnd p =
790takeEndByEsc isEsc isEnd p =
791 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
791 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
792
792
@@ -813,7 +813,7 @@ takeEndByEsc isEsc isEnd p =
813-- /Pre-release/
813-- /Pre-release/
814{-# INLINE takeFramedByEsc_ #-}
814{-# INLINE takeFramedByEsc_ #-}
815takeFramedByEsc_ :: Monad m =>
815takeFramedByEsc_ :: Monad m =>
816− (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
816+ (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
817takeFramedByEsc_ isEsc isBegin isEnd f =
817takeFramedByEsc_ isEsc isBegin isEnd f =
818 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
818 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
819-- takeEndByEsc_ isEsc isEnd p =
819-- takeEndByEsc_ isEsc isEnd p =
@@ -826,7 +826,7 @@ takeFramedByEsc_ isEsc isBegin isEnd f =
826--
826--
827{-# INLINE takeFramedBy_ #-}
827{-# INLINE takeFramedBy_ #-}
828takeFramedBy_ :: Monad m =>
828takeFramedBy_ :: Monad m =>
829− (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
829+ (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
830takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
830takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
831-- takeFramedBy_ isBegin isEnd =
831-- takeFramedBy_ isBegin isEnd =
832-- takeFramedByGeneric (Just (const False)) (Just isBegin) (Just isEnd)
832-- takeFramedByGeneric (Just (const False)) (Just isBegin) (Just isEnd)
@@ -855,7 +855,7 @@ takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
855-- @
855-- @
856--
856--
857{-# INLINE wordBy #-}
857{-# INLINE wordBy #-}
858−wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
858+wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
859wordBy f = D.toParserK . D.wordBy f
859wordBy f = D.toParserK . D.wordBy f
860
860
861-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
861-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
@@ -884,7 +884,7 @@ wordFramedBy :: Monad m =>
884 -> (a -> Bool) -- ^ right quote
884 -> (a -> Bool) -- ^ right quote
885 -> (a -> Bool) -- ^ word seperator
885 -> (a -> Bool) -- ^ word seperator
886 -> Fold m a b
886 -> Fold m a b
887− -> Parser m a b
887+ -> Parser a m b
888wordFramedBy isEsc isBegin isEnd isSpc =
888wordFramedBy isEsc isBegin isEnd isSpc =
889 D.toParserK . D.wordFramedBy isEsc isBegin isEnd isSpc
889 D.toParserK . D.wordFramedBy isEsc isBegin isEnd isSpc
890
890
@@ -917,7 +917,7 @@ wordQuotedBy :: (Monad m, Eq a) =>
917 -> (a -> a) -- ^ get right quote from left quote
917 -> (a -> a) -- ^ get right quote from left quote
918 -> (a -> Bool) -- ^ word seperator
918 -> (a -> Bool) -- ^ word seperator
919 -> Fold m a b
919 -> Fold m a b
920− -> Parser m a b
920+ -> Parser a m b
921wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
921wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
922 D.toParserK . D.wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc
922 D.toParserK . D.wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc
923
923
@@ -948,7 +948,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
948-- [[3,5,4],[1,2],[0]]
948-- [[3,5,4],[1,2],[0]]
949--
949--
950{-# INLINE groupBy #-}
950{-# INLINE groupBy #-}
951−groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
951+groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
952groupBy eq = D.toParserK . D.groupBy eq
952groupBy eq = D.toParserK . D.groupBy eq
953
953
954-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
954-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
@@ -982,7 +982,7 @@ groupBy eq = D.toParserK . D.groupBy eq
982-- /Pre-release/
982-- /Pre-release/
983--
983--
984{-# INLINE groupByRolling #-}
984{-# INLINE groupByRolling #-}
985−groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
985+groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
986groupByRolling eq = D.toParserK . D.groupByRolling eq
986groupByRolling eq = D.toParserK . D.groupByRolling eq
987
987
988-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
988-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
@@ -997,7 +997,7 @@ groupByRolling eq = D.toParserK . D.groupByRolling eq
997-- /Pre-release/
997-- /Pre-release/
998{-# INLINE groupByRollingEither #-}
998{-# INLINE groupByRollingEither #-}
999groupByRollingEither :: Monad m =>
999groupByRollingEither :: Monad m =>
1000− (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
1000+ (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (Either b c)
1001groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
1001groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
1002
1002
1003-- XXX eqBy is not a good name because we are not matching the entire stream
1003-- XXX eqBy is not a good name because we are not matching the entire stream
@@ -1010,7 +1010,7 @@ groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
1010-- See also: "Streamly.Data.Stream.eqBy"
1010-- See also: "Streamly.Data.Stream.eqBy"
1011--
1011--
1012{-# INLINE eqBy #-}
1012{-# INLINE eqBy #-}
1013−eqBy :: Monad m => (a -> a -> Bool) -> Stream m a -> Parser m a ()
1013+eqBy :: Monad m => (a -> a -> Bool) -> Stream m a -> Parser a m ()
1014eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
1014eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
1015
1015
1016-- | Match the given sequence of elements using the given comparison function.
1016-- | Match the given sequence of elements using the given comparison function.
@@ -1029,7 +1029,7 @@ eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
1029-- *** Exception: ParseError "eqBy: mismtach occurred"
1029-- *** Exception: ParseError "eqBy: mismtach occurred"
1030--
1030--
1031{-# INLINE listEqBy #-}
1031{-# INLINE listEqBy #-}
1032−listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser m a [a]
1032+listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser a m [a]
1033-- listEqBy cmp xs = D.toParserK (D.listEqBy cmp xs)
1033-- listEqBy cmp xs = D.toParserK (D.listEqBy cmp xs)
1034listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
1034listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
1035
1035
@@ -1040,7 +1040,7 @@ listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
1040-- >>> listEq = Parser.listEqBy (==)
1040-- >>> listEq = Parser.listEqBy (==)
1041--
1041--
1042{-# INLINE listEq #-}
1042{-# INLINE listEq #-}
1043−listEq :: (Monad m, Eq a) => [a] -> Parser m a [a]
1043+listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
1044listEq = listEqBy (==)
1044listEq = listEqBy (==)
1045
1045
1046-- | Match if the input stream is a subsequence of the argument stream i.e. all
1046-- | Match if the input stream is a subsequence of the argument stream i.e. all
@@ -1049,7 +1049,7 @@ listEq = listEqBy (==)
1049-- subsequence of itself.
1049-- subsequence of itself.
1050{-# INLINE subsequenceBy #-}
1050{-# INLINE subsequenceBy #-}
1051subsequenceBy :: -- Monad m =>
1051subsequenceBy :: -- Monad m =>
1052− (a -> a -> Bool) -> Stream m a -> Parser m a ()
1052+ (a -> a -> Bool) -> Stream m a -> Parser a m ()
1053subsequenceBy = undefined
1053subsequenceBy = undefined
1054
1054
1055{-
1055{-
@@ -1096,17 +1096,17 @@ regexPCRE = undefined
1096-- primitives. Some common idioms are described below,
1096-- primitives. Some common idioms are described below,
1097--
1097--
1098-- @
1098-- @
1099−-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1099+-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1100-- span pred f1 f2 = serialWith (,) ('takeWhile' pred f1) ('fromFold' f2)
1100-- span pred f1 f2 = serialWith (,) ('takeWhile' pred f1) ('fromFold' f2)
1101-- @
1101-- @
1102--
1102--
1103-- @
1103-- @
1104−-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1104+-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1105-- spanBy eq f1 f2 = serialWith (,) ('groupBy' eq f1) ('fromFold' f2)
1105-- spanBy eq f1 f2 = serialWith (,) ('groupBy' eq f1) ('fromFold' f2)
1106-- @
1106-- @
1107--
1107--
1108-- @
1108-- @
1109−-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1109+-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1110-- spanByRolling eq f1 f2 = serialWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
1110-- spanByRolling eq f1 f2 = serialWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
1111-- @
1111-- @
1112--
1112--
@@ -1114,7 +1114,7 @@ regexPCRE = undefined
1114--
1114--
1115{-# INLINE serialWith #-}
1115{-# INLINE serialWith #-}
1116serialWith :: Monad m
1116serialWith :: Monad m
1117− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1117+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1118serialWith f p1 p2 =
1118serialWith f p1 p2 =
1119 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
1119 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
1120
1120
@@ -1139,7 +1139,7 @@ serialWith f p1 p2 =
1139-- /Pre-release/
1139-- /Pre-release/
1140--
1140--
1141{-# INLINE split_ #-}
1141{-# INLINE split_ #-}
1142−split_ :: Monad m => Parser m x a -> Parser m x b -> Parser m x b
1142+split_ :: Monad m => Parser x m a -> Parser x m b -> Parser x m b
1143split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
1143split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
1144
1144
1145{-
1145{-
@@ -1151,7 +1151,7 @@ split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
1151--
1151--
1152{-# INLINE teeWith #-}
1152{-# INLINE teeWith #-}
1153teeWith :: Monad m
1153teeWith :: Monad m
1154− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1154+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1155teeWith f p1 p2 =
1155teeWith f p1 p2 =
1156 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
1156 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
1157
1157
@@ -1162,7 +1162,7 @@ teeWith f p1 p2 =
1162--
1162--
1163{-# INLINE teeWithFst #-}
1163{-# INLINE teeWithFst #-}
1164teeWithFst :: Monad m
1164teeWithFst :: Monad m
1165− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1165+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1166teeWithFst f p1 p2 =
1166teeWithFst f p1 p2 =
1167 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
1167 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
1168
1168
@@ -1173,7 +1173,7 @@ teeWithFst f p1 p2 =
1173--
1173--
1174{-# INLINE teeWithMin #-}
1174{-# INLINE teeWithMin #-}
1175teeWithMin :: Monad m
1175teeWithMin :: Monad m
1176− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1176+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1177teeWithMin f p1 p2 =
1177teeWithMin f p1 p2 =
1178 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
1178 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
1179-}
1179-}
@@ -1196,7 +1196,7 @@ teeWithMin f p1 p2 =
1196-- /Pre-release/
1196-- /Pre-release/
1197--
1197--
1198{-# INLINE alt #-}
1198{-# INLINE alt #-}
1199−alt :: Monad m => Parser m x a -> Parser m x a -> Parser m x a
1199+alt :: Monad m => Parser x m a -> Parser x m a -> Parser x m a
1200alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
1200alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
1201
1201
1202{-
1202{-
@@ -1208,7 +1208,7 @@ alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
1208--
1208--
1209{-# INLINE shortest #-}
1209{-# INLINE shortest #-}
1210shortest :: Monad m
1210shortest :: Monad m
1211− => Parser m x a -> Parser m x a -> Parser m x a
1211+ => Parser x m a -> Parser x m a -> Parser x m a
1212shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
1212shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
1213
1213
1214-- | Longest alternative. Apply both parsers in parallel but choose the result
1214-- | Longest alternative. Apply both parsers in parallel but choose the result
@@ -1219,14 +1219,14 @@ shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
1219--
1219--
1220{-# INLINE longest #-}
1220{-# INLINE longest #-}
1221longest :: Monad m
1221longest :: Monad m
1222− => Parser m x a -> Parser m x a -> Parser m x a
1222+ => Parser x m a -> Parser x m a -> Parser x m a
1223longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
1223longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
1224-}
1224-}
1225
1225
1226-- | Run a parser without consuming the input.
1226-- | Run a parser without consuming the input.
1227--
1227--
1228{-# INLINE lookAhead #-}
1228{-# INLINE lookAhead #-}
1229−lookAhead :: Monad m => Parser m a b -> Parser m a b
1229+lookAhead :: Monad m => Parser a m b -> Parser a m b
1230lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1230lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1231
1231
1232-- | Takes at-most @n@ input elements.
1232-- | Takes at-most @n@ input elements.
@@ -1242,7 +1242,7 @@ lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1242--
1242--
1243-- /Internal/
1243-- /Internal/
1244{-# INLINE takeP #-}
1244{-# INLINE takeP #-}
1245−takeP :: Monad m => Int -> Parser m a b -> Parser m a b
1245+takeP :: Monad m => Int -> Parser a m b -> Parser a m b
1246takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1246takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1247
1247
1248-------------------------------------------------------------------------------
1248-------------------------------------------------------------------------------
@@ -1261,7 +1261,7 @@ takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1261{-# INLINE concatSequence #-}
1261{-# INLINE concatSequence #-}
1262concatSequence ::
1262concatSequence ::
1263 Monad m =>
1263 Monad m =>
1264− Fold m b c -> Stream m (Parser m a b) -> Parser m a c
1264+ Fold m b c -> Stream m (Parser a m b) -> Parser a m c
1265concatSequence f p =
1265concatSequence f p =
1266 let sp = fmap D.fromParserK $ Stream.toStreamD p
1266 let sp = fmap D.fromParserK $ Stream.toStreamD p
1267 in D.toParserK $ D.sequence sp f
1267 in D.toParserK $ D.sequence sp f
@@ -1277,7 +1277,7 @@ concatSequence f p =
1277--
1277--
1278{-# INLINE concatMap #-}
1278{-# INLINE concatMap #-}
1279concatMap :: Monad m
1279concatMap :: Monad m
1280− => (b -> Parser m a c) -> Parser m a b -> Parser m a c
1280+ => (b -> Parser a m c) -> Parser a m b -> Parser a m c
1281concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
1281concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
1282
1282
1283{-
1283{-
@@ -1294,7 +1294,7 @@ concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
1294--
1294--
1295{-# INLINE choice #-}
1295{-# INLINE choice #-}
1296choice ::
1296choice ::
1297− (Functor t, Foldable t, Monad m) => t (Parser m a b) -> Parser m a b
1297+ (Functor t, Foldable t, Monad m) => t (Parser a m b) -> Parser a m b
1298choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1298choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1299-}
1299-}
1300
1300
@@ -1309,7 +1309,7 @@ choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1309--
1309--
1310{-# INLINE manyP #-}
1310{-# INLINE manyP #-}
1311manyP :: -- Monad m =>
1311manyP :: -- Monad m =>
1312− Parser m a b -> Parser m b c -> Parser m a c
1312+ Parser a m b -> Parser b m c -> Parser a m c
1313manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1313manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1314
1314
1315-- | Collect zero or more parses. Apply the supplied parser repeatedly on the
1315-- | Collect zero or more parses. Apply the supplied parser repeatedly on the
@@ -1323,7 +1323,7 @@ manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1323-- Compare with 'Control.Applicative.many'.
1323-- Compare with 'Control.Applicative.many'.
1324--
1324--
1325{-# INLINE many #-}
1325{-# INLINE many #-}
1326−many :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1326+many :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
1327many p f = D.toParserK $ D.many (D.fromParserK p) f
1327many p f = D.toParserK $ D.many (D.fromParserK p) f
1328
1328
1329-- Note: many1 would perhaps be a better name for this and consistent with
1329-- Note: many1 would perhaps be a better name for this and consistent with
@@ -1342,7 +1342,7 @@ many p f = D.toParserK $ D.many (D.fromParserK p) f
1342-- Compare with 'Control.Applicative.some'.
1342-- Compare with 'Control.Applicative.some'.
1343--
1343--
1344{-# INLINE some #-}
1344{-# INLINE some #-}
1345−some :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1345+some :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
1346some p f = D.toParserK $ D.some (D.fromParserK p) f
1346some p f = D.toParserK $ D.some (D.fromParserK p) f
1347-- some p f = manyP p (takeGE 1 f)
1347-- some p f = manyP p (takeGE 1 f)
1348-- some = countBetween 1 maxBound
1348-- some = countBetween 1 maxBound
@@ -1357,7 +1357,7 @@ some p f = D.toParserK $ D.some (D.fromParserK p) f
1357--
1357--
1358{-# INLINE countBetween #-}
1358{-# INLINE countBetween #-}
1359countBetween :: -- Monad m =>
1359countBetween :: -- Monad m =>
1360− Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
1360+ Int -> Int -> Parser a m b -> Fold m b c -> Parser a m c
1361countBetween _m _n _p = undefined
1361countBetween _m _n _p = undefined
1362-- countBetween m n p f = manyP p (takeBetween m n f)
1362-- countBetween m n p f = manyP p (takeBetween m n f)
1363
1363
@@ -1372,7 +1372,7 @@ countBetween _m _n _p = undefined
1372--
1372--
1373{-# INLINE count #-}
1373{-# INLINE count #-}
1374count :: -- Monad m =>
1374count :: -- Monad m =>
1375− Int -> Parser m a b -> Fold m b c -> Parser m a c
1375+ Int -> Parser a m b -> Fold m b c -> Parser a m c
1376count n = countBetween n n
1376count n = countBetween n n
1377-- count n p f = manyP p (takeEQ n f)
1377-- count n p f = manyP p (takeEQ n f)
1378
1378
@@ -1389,7 +1389,7 @@ count n = countBetween n n
1389--
1389--
1390{-# INLINE manyTillP #-}
1390{-# INLINE manyTillP #-}
1391manyTillP :: -- Monad m =>
1391manyTillP :: -- Monad m =>
1392− Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1392+ Parser a m b -> Parser a m x -> Parser b m c -> Parser a m c
1393manyTillP _p1 _p2 _f = undefined
1393manyTillP _p1 _p2 _f = undefined
1394 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1394 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1395
1395
@@ -1403,11 +1403,11 @@ manyTillP _p1 _p2 _f = undefined
1403--
1403--
1404{-# INLINE manyTill #-}
1404{-# INLINE manyTill #-}
1405manyTill :: Monad m
1405manyTill :: Monad m
1406− => Parser m a b -- ^ Chunking parser. Parses chunks of input.
1406+ => Parser a m b -- ^ Chunking parser. Parses chunks of input.
1407− -> Parser m a x -- ^ Test parser. Parsing stops when this parser succeeds
1407+ -> Parser a m x -- ^ Test parser. Parsing stops when this parser succeeds
1408 -- else backtract and run the chunking parser.
1408 -- else backtract and run the chunking parser.
1409 -> Fold m b c -- ^ Folds the output of the chunking parser.
1409 -> Fold m b c -- ^ Folds the output of the chunking parser.
1410− -> Parser m a c
1410+ -> Parser a m c
1411manyTill collect test f =
1411manyTill collect test f =
1412 D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
1412 D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
1413
1413
@@ -1423,7 +1423,7 @@ manyTill collect test f =
1423--
1423--
1424{-# INLINE manyThen #-}
1424{-# INLINE manyThen #-}
1425manyThen :: -- (Foldable t, Monad m) =>
1425manyThen :: -- (Foldable t, Monad m) =>
1426− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1426+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
1427manyThen _parser _recover _f = undefined
1427manyThen _parser _recover _f = undefined
1428
1428
1429-------------------------------------------------------------------------------
1429-------------------------------------------------------------------------------
@@ -1453,10 +1453,10 @@ manyThen _parser _recover _f = undefined
1453--
1453--
1454{-# INLINE deintercalate #-}
1454{-# INLINE deintercalate #-}
1455deintercalate :: Monad m =>
1455deintercalate :: Monad m =>
1456− Parser m a x
1456+ Parser a m x
1457− -> Parser m a y
1457+ -> Parser a m y
1458 -> Fold m (Either x y) z
1458 -> Fold m (Either x y) z
1459− -> Parser m a z
1459+ -> Parser a m z
1460deintercalate contentL contentR sink =
1460deintercalate contentL contentR sink =
1461 D.toParserK
1461 D.toParserK
1462 $ D.deintercalate
1462 $ D.deintercalate
@@ -1470,7 +1470,7 @@ deintercalate contentL contentR sink =
1470--
1470--
1471{-# INLINE sepBy1 #-}
1471{-# INLINE sepBy1 #-}
1472sepBy1 :: Monad m =>
1472sepBy1 :: Monad m =>
1473− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1473+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
1474sepBy1 p sep sink = do
1474sepBy1 p sep sink = do
1475 x <- p
1475 x <- p
1476 f <- fromEffect $ FL.reduce sink
1476 f <- fromEffect $ FL.reduce sink
@@ -1486,7 +1486,7 @@ sepBy1 p sep sink = do
1486--
1486--
1487{-# INLINE sepBy #-}
1487{-# INLINE sepBy #-}
1488sepBy :: Monad m =>
1488sepBy :: Monad m =>
1489− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1489+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
1490sepBy content sep sink =
1490sepBy content sep sink =
1491 D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
1491 D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
1492-- sepBy sink = deintercalate (FL.lefts sink)
1492-- sepBy sink = deintercalate (FL.lefts sink)
@@ -1503,7 +1503,7 @@ sepBy content sep sink =
1503--
1503--
1504{-# INLINE roundRobin #-}
1504{-# INLINE roundRobin #-}
1505roundRobin :: -- (Foldable t, Monad m) =>
1505roundRobin :: -- (Foldable t, Monad m) =>
1506− t (Parser m a b) -> Fold m b c -> Parser m a c
1506+ t (Parser a m b) -> Fold m b c -> Parser a m c
1507roundRobin _ps _f = undefined
1507roundRobin _ps _f = undefined
1508
1508
1509-------------------------------------------------------------------------------
1509-------------------------------------------------------------------------------
@@ -1518,7 +1518,7 @@ roundRobin _ps _f = undefined
1518--
1518--
1519{-# INLINE retryMaxTotal #-}
1519{-# INLINE retryMaxTotal #-}
1520retryMaxTotal :: -- (Monad m) =>
1520retryMaxTotal :: -- (Monad m) =>
1521− Int -> Parser m a b -> Fold m b c -> Parser m a c
1521+ Int -> Parser a m b -> Fold m b c -> Parser a m c
1522retryMaxTotal _n _p _f = undefined
1522retryMaxTotal _n _p _f = undefined
1523
1523
1524-- | Like 'retryMaxTotal' but aborts after @n@ successive failures.
1524-- | Like 'retryMaxTotal' but aborts after @n@ successive failures.
@@ -1527,7 +1527,7 @@ retryMaxTotal _n _p _f = undefined
1527--
1527--
1528{-# INLINE retryMaxSuccessive #-}
1528{-# INLINE retryMaxSuccessive #-}
1529retryMaxSuccessive :: -- (Monad m) =>
1529retryMaxSuccessive :: -- (Monad m) =>
1530− Int -> Parser m a b -> Fold m b c -> Parser m a c
1530+ Int -> Parser a m b -> Fold m b c -> Parser a m c
1531retryMaxSuccessive _n _p _f = undefined
1531retryMaxSuccessive _n _p _f = undefined
1532
1532
1533-- | Keep trying a parser until it succeeds. When the parser fails the input
1533-- | Keep trying a parser until it succeeds. When the parser fails the input
@@ -1538,5 +1538,5 @@ retryMaxSuccessive _n _p _f = undefined
1538--
1538--
1539{-# INLINE retry #-}
1539{-# INLINE retry #-}
1540retry :: -- (Monad m) =>
1540retry :: -- (Monad m) =>
1541− Parser m a b -> Parser m a b
1541+ Parser a m b -> Parser a m b
1542retry _p = undefined
1542retry _p = undefined
core/src/Streamly/Internal/Data/Parser/ParserD.hs+54−54
@@ -239,7 +239,7 @@ import Streamly.Internal.Data.Parser.ParserD.Type
239-- /Internal/
239-- /Internal/
240--
240--
241{-# INLINE toFold #-}
241{-# INLINE toFold #-}
242−toFold :: Monad m => Parser m a b -> Fold m a b
242+toFold :: Monad m => Parser a m b -> Fold m a b
243toFold (Parser pstep pinitial pextract) = Fold step initial extract
243toFold (Parser pstep pinitial pextract) = Fold step initial extract
244
244
245 where
245 where
@@ -286,7 +286,7 @@ toFold (Parser pstep pinitial pextract) = Fold step initial extract
286-- /Pre-release/
286-- /Pre-release/
287--
287--
288{-# INLINE fromFold #-}
288{-# INLINE fromFold #-}
289−fromFold :: Monad m => Fold m a b -> Parser m a b
289+fromFold :: Monad m => Fold m a b -> Parser a m b
290fromFold (Fold fstep finitial fextract) = Parser step initial extract
290fromFold (Fold fstep finitial fextract) = Parser step initial extract
291
291
292 where
292 where
@@ -312,7 +312,7 @@ fromFold (Fold fstep finitial fextract) = Parser step initial extract
312-- /Pre-release/
312-- /Pre-release/
313--
313--
314{-# INLINE fromFoldMaybe #-}
314{-# INLINE fromFoldMaybe #-}
315−fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser m a b
315+fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser a m b
316fromFoldMaybe errMsg (Fold fstep finitial fextract) =
316fromFoldMaybe errMsg (Fold fstep finitial fextract) =
317 Parser step initial extract
317 Parser step initial extract
318
318
@@ -353,7 +353,7 @@ fromFoldMaybe errMsg (Fold fstep finitial fextract) =
353-- /Pre-release/
353-- /Pre-release/
354--
354--
355{-# INLINE peek #-}
355{-# INLINE peek #-}
356−peek :: Monad m => Parser m a a
356+peek :: Monad m => Parser a m a
357peek = Parser step initial extract
357peek = Parser step initial extract
358
358
359 where
359 where
@@ -369,7 +369,7 @@ peek = Parser step initial extract
369-- /Pre-release/
369-- /Pre-release/
370--
370--
371{-# INLINE eof #-}
371{-# INLINE eof #-}
372−eof :: Monad m => Parser m a ()
372+eof :: Monad m => Parser a m ()
373eof = Parser step initial extract
373eof = Parser step initial extract
374
374
375 where
375 where
@@ -385,7 +385,7 @@ eof = Parser step initial extract
385-- /Pre-release/
385-- /Pre-release/
386--
386--
387{-# INLINE next #-}
387{-# INLINE next #-}
388−next :: Monad m => Parser m a (Maybe a)
388+next :: Monad m => Parser a m (Maybe a)
389next = Parser step initial extract
389next = Parser step initial extract
390
390
391 where
391 where
@@ -401,7 +401,7 @@ next = Parser step initial extract
401-- /Pre-release/
401-- /Pre-release/
402--
402--
403{-# INLINE either #-}
403{-# INLINE either #-}
404−either :: Monad m => (a -> Either String b) -> Parser m a b
404+either :: Monad m => (a -> Either String b) -> Parser a m b
405either f = Parser step initial extract
405either f = Parser step initial extract
406
406
407 where
407 where
@@ -423,7 +423,7 @@ either f = Parser step initial extract
423-- /Pre-release/
423-- /Pre-release/
424--
424--
425{-# INLINE maybe #-}
425{-# INLINE maybe #-}
426−maybe :: Monad m => (a -> Maybe b) -> Parser m a b
426+maybe :: Monad m => (a -> Maybe b) -> Parser a m b
427-- maybe f = either (Maybe.maybe (Left "maybe: predicate failed") Right . f)
427-- maybe f = either (Maybe.maybe (Left "maybe: predicate failed") Right . f)
428maybe parserF = Parser step initial extract
428maybe parserF = Parser step initial extract
429
429
@@ -446,7 +446,7 @@ maybe parserF = Parser step initial extract
446-- /Pre-release/
446-- /Pre-release/
447--
447--
448{-# INLINE satisfy #-}
448{-# INLINE satisfy #-}
449−satisfy :: Monad m => (a -> Bool) -> Parser m a a
449+satisfy :: Monad m => (a -> Bool) -> Parser a m a
450-- satisfy predicate = maybe (\a -> if predicate a then Just a else Nothing)
450-- satisfy predicate = maybe (\a -> if predicate a then Just a else Nothing)
451satisfy predicate = Parser step initial extract
451satisfy predicate = Parser step initial extract
452
452
@@ -474,7 +474,7 @@ data Tuple'Fused a b = Tuple'Fused !a !b deriving Show
474-- /Pre-release/
474-- /Pre-release/
475--
475--
476{-# INLINE takeBetween #-}
476{-# INLINE takeBetween #-}
477−takeBetween :: Monad m => Int -> Int -> Fold m a b -> Parser m a b
477+takeBetween :: Monad m => Int -> Int -> Fold m a b -> Parser a m b
478takeBetween low high (Fold fstep finitial fextract) =
478takeBetween low high (Fold fstep finitial fextract) =
479
479
480 Parser step initial (extract streamErr)
480 Parser step initial (extract streamErr)
@@ -551,7 +551,7 @@ takeBetween low high (Fold fstep finitial fextract) =
551-- /Pre-release/
551-- /Pre-release/
552--
552--
553{-# INLINE takeEQ #-}
553{-# INLINE takeEQ #-}
554−takeEQ :: Monad m => Int -> Fold m a b -> Parser m a b
554+takeEQ :: Monad m => Int -> Fold m a b -> Parser a m b
555takeEQ n (Fold fstep finitial fextract) = Parser step initial extract
555takeEQ n (Fold fstep finitial fextract) = Parser step initial extract
556
556
557 where
557 where
@@ -607,7 +607,7 @@ takeEQ n (Fold fstep finitial fextract) = Parser step initial extract
607-- /Pre-release/
607-- /Pre-release/
608--
608--
609{-# INLINE takeGE #-}
609{-# INLINE takeGE #-}
610−takeGE :: Monad m => Int -> Fold m a b -> Parser m a b
610+takeGE :: Monad m => Int -> Fold m a b -> Parser a m b
611takeGE n (Fold fstep finitial fextract) = Parser step initial extract
611takeGE n (Fold fstep finitial fextract) = Parser step initial extract
612
612
613 where
613 where
@@ -664,7 +664,7 @@ takeGE n (Fold fstep finitial fextract) = Parser step initial extract
664-- /Pre-release/
664-- /Pre-release/
665--
665--
666{-# INLINE takeWhileP #-}
666{-# INLINE takeWhileP #-}
667−takeWhileP :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
667+takeWhileP :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
668takeWhileP predicate (Parser pstep pinitial pextract) =
668takeWhileP predicate (Parser pstep pinitial pextract) =
669 Parser step pinitial pextract
669 Parser step pinitial pextract
670
670
@@ -687,7 +687,7 @@ takeWhileP predicate (Parser pstep pinitial pextract) =
687-- /Pre-release/
687-- /Pre-release/
688--
688--
689{-# INLINE takeWhile #-}
689{-# INLINE takeWhile #-}
690−takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
690+takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
691takeWhile predicate (Fold fstep finitial fextract) =
691takeWhile predicate (Fold fstep finitial fextract) =
692 Parser step initial extract
692 Parser step initial extract
693
693
@@ -716,7 +716,7 @@ takeWhile predicate (Fold fstep finitial fextract) =
716-- /Pre-release/
716-- /Pre-release/
717--
717--
718{-# INLINE takeWhile1 #-}
718{-# INLINE takeWhile1 #-}
719−takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
719+takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
720takeWhile1 predicate (Fold fstep finitial fextract) =
720takeWhile1 predicate (Fold fstep finitial fextract) =
721 Parser step initial extract
721 Parser step initial extract
722
722
@@ -766,7 +766,7 @@ takeFramedByGeneric :: Monad m =>
766 -> Maybe (a -> Bool)
766 -> Maybe (a -> Bool)
767 -> Maybe (a -> Bool)
767 -> Maybe (a -> Bool)
768 -> Fold m a b
768 -> Fold m a b
769− -> Parser m a b
769+ -> Parser a m b
770takeFramedByGeneric esc begin end (Fold fstep finitial fextract) =
770takeFramedByGeneric esc begin end (Fold fstep finitial fextract) =
771
771
772 Parser step initial extract
772 Parser step initial extract
@@ -862,7 +862,7 @@ takeFramedByGeneric esc begin end (Fold fstep finitial fextract) =
862-- /Pre-release/
862-- /Pre-release/
863--
863--
864{-# INLINE takeEndBy #-}
864{-# INLINE takeEndBy #-}
865−takeEndBy :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
865+takeEndBy :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
866takeEndBy cond (Parser pstep pinitial pextract) =
866takeEndBy cond (Parser pstep pinitial pextract) =
867
867
868 Parser step initial pextract
868 Parser step initial pextract
@@ -883,7 +883,7 @@ takeEndBy cond (Parser pstep pinitial pextract) =
883--
883--
884{-# INLINE takeEndByEsc #-}
884{-# INLINE takeEndByEsc #-}
885takeEndByEsc :: Monad m =>
885takeEndByEsc :: Monad m =>
886− (a -> Bool) -> (a -> Bool) -> Parser m a b -> Parser m a b
886+ (a -> Bool) -> (a -> Bool) -> Parser a m b -> Parser a m b
887takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
887takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
888
888
889 Parser step initial extract
889 Parser step initial extract
@@ -914,7 +914,7 @@ takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
914-- /Pre-release/
914-- /Pre-release/
915--
915--
916{-# INLINE takeEndBy_ #-}
916{-# INLINE takeEndBy_ #-}
917−takeEndBy_ :: (a -> Bool) -> Parser m a b -> Parser m a b
917+takeEndBy_ :: (a -> Bool) -> Parser a m b -> Parser a m b
918takeEndBy_ cond (Parser pstep pinitial pextract) =
918takeEndBy_ cond (Parser pstep pinitial pextract) =
919
919
920 Parser step pinitial pextract
920 Parser step pinitial pextract
@@ -932,7 +932,7 @@ takeEndBy_ cond (Parser pstep pinitial pextract) =
932--
932--
933
933
934{-# INLINE takeStartBy #-}
934{-# INLINE takeStartBy #-}
935−takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
935+takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
936takeStartBy cond (Fold fstep finitial fextract) =
936takeStartBy cond (Fold fstep finitial fextract) =
937
937
938 Parser step initial extract
938 Parser step initial extract
@@ -968,7 +968,7 @@ takeStartBy cond (Fold fstep finitial fextract) =
968
968
969{-# INLINE takeFramedByEsc_ #-}
969{-# INLINE takeFramedByEsc_ #-}
970takeFramedByEsc_ :: Monad m =>
970takeFramedByEsc_ :: Monad m =>
971− (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
971+ (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
972takeFramedByEsc_ isEsc isBegin isEnd (Fold fstep finitial fextract) =
972takeFramedByEsc_ isEsc isBegin isEnd (Fold fstep finitial fextract) =
973
973
974 Parser step initial extract
974 Parser step initial extract
@@ -1019,7 +1019,7 @@ data FramedState s = FrameInit !s | FrameGo !s Int
1019
1019
1020{-# INLINE takeFramedBy_ #-}
1020{-# INLINE takeFramedBy_ #-}
1021takeFramedBy_ :: Monad m =>
1021takeFramedBy_ :: Monad m =>
1022− (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
1022+ (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
1023takeFramedBy_ isBegin isEnd (Fold fstep finitial fextract) =
1023takeFramedBy_ isBegin isEnd (Fold fstep finitial fextract) =
1024
1024
1025 Parser step initial extract
1025 Parser step initial extract
@@ -1068,7 +1068,7 @@ data WordByState s b = WBLeft !s | WBWord !s | WBRight !b
1068--
1068--
1069--
1069--
1070{-# INLINE wordBy #-}
1070{-# INLINE wordBy #-}
1071−wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
1071+wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
1072wordBy predicate (Fold fstep finitial fextract) = Parser step initial extract
1072wordBy predicate (Fold fstep finitial fextract) = Parser step initial extract
1073
1073
1074 where
1074 where
@@ -1123,7 +1123,7 @@ wordFramedBy :: Monad m =>
1123 -> (a -> Bool) -- ^ right quote
1123 -> (a -> Bool) -- ^ right quote
1124 -> (a -> Bool) -- ^ word seperator
1124 -> (a -> Bool) -- ^ word seperator
1125 -> Fold m a b
1125 -> Fold m a b
1126− -> Parser m a b
1126+ -> Parser a m b
1127wordFramedBy isEsc isBegin isEnd isSep
1127wordFramedBy isEsc isBegin isEnd isSep
1128 (Fold fstep finitial fextract) =
1128 (Fold fstep finitial fextract) =
1129 Parser step initial extract
1129 Parser step initial extract
@@ -1215,7 +1215,7 @@ wordQuotedBy :: (Monad m, Eq a) =>
1215 -> (a -> a) -- ^ get right quote from the left quote
1215 -> (a -> a) -- ^ get right quote from the left quote
1216 -> (a -> Bool) -- ^ word seperator
1216 -> (a -> Bool) -- ^ word seperator
1217 -> Fold m a b
1217 -> Fold m a b
1218− -> Parser m a b
1218+ -> Parser a m b
1219wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSep
1219wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSep
1220 (Fold fstep finitial fextract) =
1220 (Fold fstep finitial fextract) =
1221 Parser step initial extract
1221 Parser step initial extract
@@ -1316,7 +1316,7 @@ data GroupByState a s
1316-- | See 'Streamly.Internal.Data.Parser.groupBy'.
1316-- | See 'Streamly.Internal.Data.Parser.groupBy'.
1317--
1317--
1318{-# INLINE groupBy #-}
1318{-# INLINE groupBy #-}
1319−groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
1319+groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
1320groupBy eq (Fold fstep finitial fextract) = Parser step initial extract
1320groupBy eq (Fold fstep finitial fextract) = Parser step initial extract
1321
1321
1322 where
1322 where
@@ -1348,7 +1348,7 @@ groupBy eq (Fold fstep finitial fextract) = Parser step initial extract
1348-- | See 'Streamly.Internal.Data.Parser.groupByRolling'.
1348-- | See 'Streamly.Internal.Data.Parser.groupByRolling'.
1349--
1349--
1350{-# INLINE groupByRolling #-}
1350{-# INLINE groupByRolling #-}
1351−groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
1351+groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
1352groupByRolling eq (Fold fstep finitial fextract) = Parser step initial extract
1352groupByRolling eq (Fold fstep finitial fextract) = Parser step initial extract
1353
1353
1354 where
1354 where
@@ -1386,7 +1386,7 @@ data GroupByStatePair a s1 s2
1386
1386
1387{-# INLINE groupByRollingEither #-}
1387{-# INLINE groupByRollingEither #-}
1388groupByRollingEither :: Monad m =>
1388groupByRollingEither :: Monad m =>
1389− (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
1389+ (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (Either b c)
1390groupByRollingEither
1390groupByRollingEither
1391 eq
1391 eq
1392 (Fold fstep1 finitial1 fextract1)
1392 (Fold fstep1 finitial1 fextract1)
@@ -1474,7 +1474,7 @@ groupByRollingEither
1474-- /Pre-release/
1474-- /Pre-release/
1475--
1475--
1476{-# INLINE listEqBy #-}
1476{-# INLINE listEqBy #-}
1477−listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser m a [a]
1477+listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser a m [a]
1478listEqBy cmp str = Parser step initial extract
1478listEqBy cmp str = Parser step initial extract
1479
1479
1480 where
1480 where
@@ -1504,7 +1504,7 @@ listEqBy cmp str = Parser step initial extract
1504
1504
1505-- | Like 'listEqBy' but uses a stream instead of a list
1505-- | Like 'listEqBy' but uses a stream instead of a list
1506{-# INLINE eqBy #-}
1506{-# INLINE eqBy #-}
1507−eqBy :: Monad m => (a -> a -> Bool) -> D.Stream m a -> Parser m a ()
1507+eqBy :: Monad m => (a -> a -> Bool) -> D.Stream m a -> Parser a m ()
1508eqBy cmp (D.Stream sstep state) = Parser step initial extract
1508eqBy cmp (D.Stream sstep state) = Parser step initial extract
1509
1509
1510 where
1510 where
@@ -1555,12 +1555,12 @@ eqBy cmp (D.Stream sstep state) = Parser step initial extract
1555--
1555--
1556{-# INLINE postscan #-}
1556{-# INLINE postscan #-}
1557postscan :: -- Monad m =>
1557postscan :: -- Monad m =>
1558− Fold m a b -> Parser m b c -> Parser m a c
1558+ Fold m a b -> Parser b m c -> Parser a m c
1559postscan = undefined
1559postscan = undefined
1560
1560
1561{-# INLINE zipWithM #-}
1561{-# INLINE zipWithM #-}
1562zipWithM :: Monad m =>
1562zipWithM :: Monad m =>
1563− (a -> b -> m c) -> D.Stream m a -> Fold m c x -> Parser m b x
1563+ (a -> b -> m c) -> D.Stream m a -> Fold m c x -> Parser b m x
1564zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
1564zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
1565 Parser step initial extract
1565 Parser step initial extract
1566
1566
@@ -1615,14 +1615,14 @@ zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
1615-- /Pre-release/
1615-- /Pre-release/
1616--
1616--
1617{-# INLINE zip #-}
1617{-# INLINE zip #-}
1618−zip :: Monad m => D.Stream m a -> Fold m (a, b) x -> Parser m b x
1618+zip :: Monad m => D.Stream m a -> Fold m (a, b) x -> Parser b m x
1619zip = zipWithM (curry return)
1619zip = zipWithM (curry return)
1620
1620
1621-- | Pair each element of a fold input with its index, starting from index 0.
1621-- | Pair each element of a fold input with its index, starting from index 0.
1622--
1622--
1623-- /Pre-release/
1623-- /Pre-release/
1624{-# INLINE indexed #-}
1624{-# INLINE indexed #-}
1625−indexed :: forall m a b. Monad m => Fold m (Int, a) b -> Parser m a b
1625+indexed :: forall m a b. Monad m => Fold m (Int, a) b -> Parser a m b
1626indexed = zip (D.enumerateFromIntegral 0 :: D.Stream m Int)
1626indexed = zip (D.enumerateFromIntegral 0 :: D.Stream m Int)
1627
1627
1628-- | @makeIndexFilter indexer filter predicate@ generates a fold filtering
1628-- | @makeIndexFilter indexer filter predicate@ generates a fold filtering
@@ -1641,9 +1641,9 @@ indexed = zip (D.enumerateFromIntegral 0 :: D.Stream m Int)
1641-- /Pre-release/
1641-- /Pre-release/
1642{-# INLINE makeIndexFilter #-}
1642{-# INLINE makeIndexFilter #-}
1643makeIndexFilter ::
1643makeIndexFilter ::
1644− (Fold m (s, a) b -> Parser m a b)
1644+ (Fold m (s, a) b -> Parser a m b)
1645 -> (((s, a) -> Bool) -> Fold m (s, a) b -> Fold m (s, a) b)
1645 -> (((s, a) -> Bool) -> Fold m (s, a) b -> Fold m (s, a) b)
1646− -> (((s, a) -> Bool) -> Fold m a b -> Parser m a b)
1646+ -> (((s, a) -> Bool) -> Fold m a b -> Parser a m b)
1647makeIndexFilter f comb g = f . comb g . FL.lmap snd
1647makeIndexFilter f comb g = f . comb g . FL.lmap snd
1648
1648
1649-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
1649-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
@@ -1651,7 +1651,7 @@ makeIndexFilter f comb g = f . comb g . FL.lmap snd
1651--
1651--
1652-- /Pre-release/
1652-- /Pre-release/
1653{-# INLINE sampleFromthen #-}
1653{-# INLINE sampleFromthen #-}
1654−sampleFromthen :: Monad m => Int -> Int -> Fold m a b -> Parser m a b
1654+sampleFromthen :: Monad m => Int -> Int -> Fold m a b -> Parser a m b
1655sampleFromthen offset size =
1655sampleFromthen offset size =
1656 makeIndexFilter indexed FL.filter (\(i, _) -> (i + offset) `mod` size == 0)
1656 makeIndexFilter indexed FL.filter (\(i, _) -> (i + offset) `mod` size == 0)
1657
1657
@@ -1679,7 +1679,7 @@ sampleFromthen offset size =
1679--
1679--
1680-- /Pre-release/
1680-- /Pre-release/
1681{-# INLINE span #-}
1681{-# INLINE span #-}
1682−span :: Monad m => (a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (b, c)
1682+span :: Monad m => (a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (b, c)
1683span p f1 f2 = noErrorUnsafeSplitWith (,) (takeWhile p f1) (fromFold f2)
1683span p f1 f2 = noErrorUnsafeSplitWith (,) (takeWhile p f1) (fromFold f2)
1684
1684
1685-- | Break the input stream into two groups, the first group takes the input as
1685-- | Break the input stream into two groups, the first group takes the input as
@@ -1691,7 +1691,7 @@ span p f1 f2 = noErrorUnsafeSplitWith (,) (takeWhile p f1) (fromFold f2)
1691{-# INLINE spanBy #-}
1691{-# INLINE spanBy #-}
1692spanBy ::
1692spanBy ::
1693 Monad m
1693 Monad m
1694− => (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (b, c)
1694+ => (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (b, c)
1695spanBy eq f1 f2 = noErrorUnsafeSplitWith (,) (groupBy eq f1) (fromFold f2)
1695spanBy eq f1 f2 = noErrorUnsafeSplitWith (,) (groupBy eq f1) (fromFold f2)
1696
1696
1697-- | Like 'spanBy' but applies the predicate in a rolling fashion i.e.
1697-- | Like 'spanBy' but applies the predicate in a rolling fashion i.e.
@@ -1701,7 +1701,7 @@ spanBy eq f1 f2 = noErrorUnsafeSplitWith (,) (groupBy eq f1) (fromFold f2)
1701{-# INLINE spanByRolling #-}
1701{-# INLINE spanByRolling #-}
1702spanByRolling ::
1702spanByRolling ::
1703 Monad m
1703 Monad m
1704− => (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (b, c)
1704+ => (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (b, c)
1705spanByRolling eq f1 f2 =
1705spanByRolling eq f1 f2 =
1706 noErrorUnsafeSplitWith (,) (groupByRolling eq f1) (fromFold f2)
1706 noErrorUnsafeSplitWith (,) (groupByRolling eq f1) (fromFold f2)
1707
1707
@@ -1713,7 +1713,7 @@ spanByRolling eq f1 f2 =
1713--
1713--
1714-- /Internal/
1714-- /Internal/
1715{-# INLINE takeP #-}
1715{-# INLINE takeP #-}
1716−takeP :: Monad m => Int -> Parser m a b -> Parser m a b
1716+takeP :: Monad m => Int -> Parser a m b -> Parser a m b
1717takeP lim (Parser pstep pinitial pextract) = Parser step initial extract
1717takeP lim (Parser pstep pinitial pextract) = Parser step initial extract
1718
1718
1719 where
1719 where
@@ -1788,7 +1788,7 @@ takeP lim (Parser pstep pinitial pextract) = Parser step initial extract
1788-- /Pre-release/
1788-- /Pre-release/
1789--
1789--
1790{-# INLINE lookAhead #-}
1790{-# INLINE lookAhead #-}
1791−lookAhead :: Monad m => Parser m a b -> Parser m a b
1791+lookAhead :: Monad m => Parser a m b -> Parser a m b
1792lookAhead (Parser step1 initial1 _) = Parser step initial extract
1792lookAhead (Parser step1 initial1 _) = Parser step initial extract
1793
1793
1794 where
1794 where
@@ -1833,10 +1833,10 @@ data DeintercalateState fs sp ss =
1833--
1833--
1834{-# INLINE deintercalate #-}
1834{-# INLINE deintercalate #-}
1835deintercalate :: Monad m =>
1835deintercalate :: Monad m =>
1836− Parser m a x
1836+ Parser a m x
1837− -> Parser m a y
1837+ -> Parser a m y
1838 -> Fold m (Either x y) z
1838 -> Fold m (Either x y) z
1839− -> Parser m a z
1839+ -> Parser a m z
1840deintercalate
1840deintercalate
1841 (Parser stepL initialL extractL)
1841 (Parser stepL initialL extractL)
1842 (Parser stepR initialR extractR)
1842 (Parser stepR initialR extractR)
@@ -1930,7 +1930,7 @@ data SepByState fs sp ss =
1930-- terms of deintercalate.
1930-- terms of deintercalate.
1931{-# INLINE sepBy #-}
1931{-# INLINE sepBy #-}
1932sepBy :: Monad m =>
1932sepBy :: Monad m =>
1933− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1933+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
1934sepBy
1934sepBy
1935 (Parser pstep pinitial pextract)
1935 (Parser pstep pinitial pextract)
1936 (Parser sstep sinitial _)
1936 (Parser sstep sinitial _)
@@ -2007,7 +2007,7 @@ sepBy
2007-- | See 'Streamly.Internal.Data.Parser.sequence'.
2007-- | See 'Streamly.Internal.Data.Parser.sequence'.
2008{-# INLINE sequence #-}
2008{-# INLINE sequence #-}
2009sequence :: Monad m =>
2009sequence :: Monad m =>
2010− D.Stream m (Parser m a b) -> Fold m b c -> Parser m a c
2010+ D.Stream m (Parser a m b) -> Fold m b c -> Parser a m c
2011sequence (D.Stream sstep sstate) (Fold fstep finitial fextract) =
2011sequence (D.Stream sstep sstate) (Fold fstep finitial fextract) =
2012 Parser step initial extract
2012 Parser step initial extract
2013
2013
@@ -2094,7 +2094,7 @@ sequence (D.Stream sstep sstate) (Fold fstep finitial fextract) =
2094-- /Broken/
2094-- /Broken/
2095--
2095--
2096{-# INLINE choice #-}
2096{-# INLINE choice #-}
2097−choice :: (MonadCatch m, Foldable t) => t (Parser m a b) -> Parser m a b
2097+choice :: (MonadCatch m, Foldable t) => t (Parser a m b) -> Parser a m b
2098choice = foldl1 shortest
2098choice = foldl1 shortest
2099-}
2099-}
2100
2100
@@ -2104,7 +2104,7 @@ choice = foldl1 shortest
2104
2104
2105{-# INLINE manyP #-}
2105{-# INLINE manyP #-}
2106manyP :: -- MonadCatch m =>
2106manyP :: -- MonadCatch m =>
2107− Parser m a b -> Parser m b c -> Parser m a c
2107+ Parser a m b -> Parser b m c -> Parser a m c
2108manyP _p _f = undefined
2108manyP _p _f = undefined
2109
2109
2110-- | See 'Streamly.Internal.Data.Parser.many'.
2110-- | See 'Streamly.Internal.Data.Parser.many'.
@@ -2112,7 +2112,7 @@ manyP _p _f = undefined
2112-- /Pre-release/
2112-- /Pre-release/
2113--
2113--
2114{-# INLINE many #-}
2114{-# INLINE many #-}
2115−many :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
2115+many :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
2116many = splitMany
2116many = splitMany
2117-- many = countBetween 0 maxBound
2117-- many = countBetween 0 maxBound
2118
2118
@@ -2121,7 +2121,7 @@ many = splitMany
2121-- /Pre-release/
2121-- /Pre-release/
2122--
2122--
2123{-# INLINE some #-}
2123{-# INLINE some #-}
2124−some :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
2124+some :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
2125some = splitSome
2125some = splitSome
2126-- some p f = manyP p (takeGE 1 f)
2126-- some p f = manyP p (takeGE 1 f)
2127-- some = countBetween 1 maxBound
2127-- some = countBetween 1 maxBound
@@ -2132,7 +2132,7 @@ some = splitSome
2132--
2132--
2133{-# INLINE countBetween #-}
2133{-# INLINE countBetween #-}
2134countBetween :: -- MonadCatch m =>
2134countBetween :: -- MonadCatch m =>
2135− Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
2135+ Int -> Int -> Parser a m b -> Fold m b c -> Parser a m c
2136countBetween _m _n _p = undefined
2136countBetween _m _n _p = undefined
2137-- countBetween m n p f = manyP p (takeBetween m n f)
2137-- countBetween m n p f = manyP p (takeBetween m n f)
2138
2138
@@ -2142,7 +2142,7 @@ countBetween _m _n _p = undefined
2142--
2142--
2143{-# INLINE count #-}
2143{-# INLINE count #-}
2144count :: -- MonadCatch m =>
2144count :: -- MonadCatch m =>
2145− Int -> Parser m a b -> Fold m b c -> Parser m a c
2145+ Int -> Parser a m b -> Fold m b c -> Parser a m c
2146count n = countBetween n n
2146count n = countBetween n n
2147-- count n p f = manyP p (takeEQ n f)
2147-- count n p f = manyP p (takeEQ n f)
2148
2148
@@ -2156,7 +2156,7 @@ data ManyTillState fs sr sl
2156--
2156--
2157{-# INLINE manyTill #-}
2157{-# INLINE manyTill #-}
2158manyTill :: Monad m
2158manyTill :: Monad m
2159− => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
2159+ => Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
2160manyTill (Parser stepL initialL extractL)
2160manyTill (Parser stepL initialL extractL)
2161 (Parser stepR initialR _)
2161 (Parser stepR initialR _)
2162 (Fold fstep finitial fextract) =
2162 (Fold fstep finitial fextract) =
core/src/Streamly/Internal/Data/Parser/ParserD/Tee.hs+5−5
@@ -104,7 +104,7 @@ data Res = Yld Int | Stp Int | Skp | Err String
104--
104--
105{-# INLINE teeWith #-}
105{-# INLINE teeWith #-}
106teeWith :: Monad m
106teeWith :: Monad m
107− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
107+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
108teeWith zf (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
108teeWith zf (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
109 Parser step initial extract
109 Parser step initial extract
110
110
@@ -246,7 +246,7 @@ teeWith zf (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
246--
246--
247{-# INLINE teeWithFst #-}
247{-# INLINE teeWithFst #-}
248teeWithFst :: Monad m
248teeWithFst :: Monad m
249− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
249+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
250teeWithFst zf (Parser stepL initialL extractL)
250teeWithFst zf (Parser stepL initialL extractL)
251 (Parser stepR initialR extractR) =
251 (Parser stepR initialR extractR) =
252 Parser step initial extract
252 Parser step initial extract
@@ -370,7 +370,7 @@ teeWithFst zf (Parser stepL initialL extractL)
370{-# INLINE teeWithMin #-}
370{-# INLINE teeWithMin #-}
371teeWithMin ::
371teeWithMin ::
372 -- Monad m =>
372 -- Monad m =>
373− (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
373+ (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
374teeWithMin = undefined
374teeWithMin = undefined
375
375
376-------------------------------------------------------------------------------
376-------------------------------------------------------------------------------
@@ -382,7 +382,7 @@ teeWithMin = undefined
382-- /Broken/
382-- /Broken/
383--
383--
384{-# INLINE shortest #-}
384{-# INLINE shortest #-}
385−shortest :: Monad m => Parser m x a -> Parser m x a -> Parser m x a
385+shortest :: Monad m => Parser x m a -> Parser x m a -> Parser x m a
386shortest (Parser stepL initialL extractL) (Parser stepR initialR _) =
386shortest (Parser stepL initialL extractL) (Parser stepR initialR _) =
387 Parser step initial extract
387 Parser step initial extract
388
388
@@ -471,7 +471,7 @@ shortest (Parser stepL initialL extractL) (Parser stepR initialR _) =
471-- /Broken/
471-- /Broken/
472--
472--
473{-# INLINE longest #-}
473{-# INLINE longest #-}
474−longest :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a
474+longest :: MonadCatch m => Parser x m a -> Parser x m a -> Parser x m a
475longest (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
475longest (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
476 Parser step initial extract
476 Parser step initial extract
477
477
core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+29−29
@@ -417,7 +417,7 @@ mapMStep f res =
417--
417--
418-- /Pre-release/
418-- /Pre-release/
419--
419--
420−data Parser m a b =
420+data Parser a m b =
421 forall s. Parser
421 forall s. Parser
422 (s -> a -> m (Step s b))
422 (s -> a -> m (Step s b))
423 -- Initial cannot return "Partial/Done n" or "Continue". Continue 0 is
423 -- Initial cannot return "Partial/Done n" or "Continue". Continue 0 is
@@ -439,7 +439,7 @@ newtype ParseError = ParseError String
439instance Exception ParseError where
439instance Exception ParseError where
440 displayException (ParseError err) = err
440 displayException (ParseError err) = err
441
441
442−instance Functor m => Functor (Parser m a) where
442+instance Functor m => Functor (Parser a m) where
443 {-# INLINE fmap #-}
443 {-# INLINE fmap #-}
444 fmap f (Parser step1 initial1 extract) =
444 fmap f (Parser step1 initial1 extract) =
445 Parser step initial (fmap3 f extract)
445 Parser step initial (fmap3 f extract)
@@ -565,7 +565,7 @@ parseDToK pstep initial extract leftover (level, count) cont = do
565-- /Pre-release/
565-- /Pre-release/
566--
566--
567{-# INLINE_LATE toParserK #-}
567{-# INLINE_LATE toParserK #-}
568−toParserK :: Monad m => Parser m a b -> K.Parser m a b
568+toParserK :: Monad m => Parser a m b -> K.Parser a m b
569toParserK (Parser step initial extract) =
569toParserK (Parser step initial extract) =
570 K.MkParser $ parseDToK step initial extract
570 K.MkParser $ parseDToK step initial extract
571
571
@@ -589,7 +589,7 @@ parserDone st _ =
589-- /Pre-release/
589-- /Pre-release/
590--
590--
591{-# INLINE_LATE fromParserK #-}
591{-# INLINE_LATE fromParserK #-}
592−fromParserK :: Monad m => K.Parser m a b -> Parser m a b
592+fromParserK :: Monad m => K.Parser a m b -> Parser a m b
593fromParserK parser = Parser step initial extract
593fromParserK parser = Parser step initial extract
594
594
595 where
595 where
@@ -633,7 +633,7 @@ fromParserK parser = Parser step initial extract
633--
633--
634-- /Pre-release/
634-- /Pre-release/
635{-# INLINE rmapM #-}
635{-# INLINE rmapM #-}
636−rmapM :: Monad m => (b -> m c) -> Parser m a b -> Parser m a c
636+rmapM :: Monad m => (b -> m c) -> Parser a m b -> Parser a m c
637rmapM f (Parser step initial extract) =
637rmapM f (Parser step initial extract) =
638 Parser step1 initial1 (extract >=> mapMStep f)
638 Parser step1 initial1 (extract >=> mapMStep f)
639
639
@@ -653,7 +653,7 @@ rmapM f (Parser step initial extract) =
653-- /Pre-release/
653-- /Pre-release/
654--
654--
655{-# INLINE_NORMAL fromPure #-}
655{-# INLINE_NORMAL fromPure #-}
656−fromPure :: Monad m => b -> Parser m a b
656+fromPure :: Monad m => b -> Parser a m b
657fromPure b = Parser undefined (pure $ IDone b) undefined
657fromPure b = Parser undefined (pure $ IDone b) undefined
658
658
659-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
659-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
@@ -661,7 +661,7 @@ fromPure b = Parser undefined (pure $ IDone b) undefined
661-- /Pre-release/
661-- /Pre-release/
662--
662--
663{-# INLINE fromEffect #-}
663{-# INLINE fromEffect #-}
664−fromEffect :: Monad m => m b -> Parser m a b
664+fromEffect :: Monad m => m b -> Parser a m b
665fromEffect b = Parser undefined (IDone <$> b) undefined
665fromEffect b = Parser undefined (IDone <$> b) undefined
666
666
667-------------------------------------------------------------------------------
667-------------------------------------------------------------------------------
@@ -684,7 +684,7 @@ data SeqParseState sl f sr = SeqParseL sl | SeqParseR f sr
684--
684--
685{-# INLINE serialWith #-}
685{-# INLINE serialWith #-}
686serialWith :: Monad m
686serialWith :: Monad m
687− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
687+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
688serialWith func (Parser stepL initialL extractL)
688serialWith func (Parser stepL initialL extractL)
689 (Parser stepR initialR extractR) =
689 (Parser stepR initialR extractR) =
690 Parser step initial extract
690 Parser step initial extract
@@ -767,7 +767,7 @@ serialWith func (Parser stepL initialL extractL)
767-- | Works correctly only if both the parsers are guaranteed to never fail.
767-- | Works correctly only if both the parsers are guaranteed to never fail.
768{-# INLINE noErrorUnsafeSplitWith #-}
768{-# INLINE noErrorUnsafeSplitWith #-}
769noErrorUnsafeSplitWith :: Monad m
769noErrorUnsafeSplitWith :: Monad m
770− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
770+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
771noErrorUnsafeSplitWith func (Parser stepL initialL extractL)
771noErrorUnsafeSplitWith func (Parser stepL initialL extractL)
772 (Parser stepR initialR extractR) =
772 (Parser stepR initialR extractR) =
773 Parser step initial extract
773 Parser step initial extract
@@ -833,7 +833,7 @@ data SeqAState sl sr = SeqAL sl | SeqAR sr
833-- /Pre-release/
833-- /Pre-release/
834--
834--
835{-# INLINE split_ #-}
835{-# INLINE split_ #-}
836−split_ :: Monad m => Parser m x a -> Parser m x b -> Parser m x b
836+split_ :: Monad m => Parser x m a -> Parser x m b -> Parser x m b
837split_ (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
837split_ (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
838 Parser step initial extract
838 Parser step initial extract
839
839
@@ -887,7 +887,7 @@ split_ (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
887
887
888-- For backtracking folds
888-- For backtracking folds
889{-# INLINE noErrorUnsafeSplit_ #-}
889{-# INLINE noErrorUnsafeSplit_ #-}
890−noErrorUnsafeSplit_ :: Monad m => Parser m x a -> Parser m x b -> Parser m x b
890+noErrorUnsafeSplit_ :: Monad m => Parser x m a -> Parser x m b -> Parser x m b
891noErrorUnsafeSplit_
891noErrorUnsafeSplit_
892 (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
892 (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
893 Parser step initial extract
893 Parser step initial extract
@@ -941,7 +941,7 @@ noErrorUnsafeSplit_
941 Continue n s -> return $ Continue n (SeqAL s)
941 Continue n s -> return $ Continue n (SeqAL s)
942
942
943-- | 'Applicative' form of 'serialWith'.
943-- | 'Applicative' form of 'serialWith'.
944−instance Monad m => Applicative (Parser m a) where
944+instance Monad m => Applicative (Parser a m) where
945 {-# INLINE pure #-}
945 {-# INLINE pure #-}
946 pure = fromPure
946 pure = fromPure
947
947
@@ -973,7 +973,7 @@ data AltParseState sl sr = AltParseL Int sl | AltParseR sr
973-- /Pre-release/
973-- /Pre-release/
974--
974--
975{-# INLINE alt #-}
975{-# INLINE alt #-}
976−alt :: Monad m => Parser m x a -> Parser m x a -> Parser m x a
976+alt :: Monad m => Parser x m a -> Parser x m a -> Parser x m a
977alt (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
977alt (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
978 Parser step initial extract
978 Parser step initial extract
979
979
@@ -1043,7 +1043,7 @@ alt (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
1043-- /Pre-release/
1043-- /Pre-release/
1044--
1044--
1045{-# INLINE splitMany #-}
1045{-# INLINE splitMany #-}
1046−splitMany :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1046+splitMany :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
1047splitMany (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1047splitMany (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1048 Parser step initial extract
1048 Parser step initial extract
1049
1049
@@ -1107,7 +1107,7 @@ splitMany (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1107-- /Internal/
1107-- /Internal/
1108--
1108--
1109{-# INLINE splitManyPost #-}
1109{-# INLINE splitManyPost #-}
1110−splitManyPost :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1110+splitManyPost :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
1111splitManyPost (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1111splitManyPost (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1112 Parser step initial extract
1112 Parser step initial extract
1113
1113
@@ -1169,7 +1169,7 @@ splitManyPost (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1169-- /Pre-release/
1169-- /Pre-release/
1170--
1170--
1171{-# INLINE splitSome #-}
1171{-# INLINE splitSome #-}
1172−splitSome :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1172+splitSome :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
1173splitSome (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1173splitSome (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1174 Parser step initial extract
1174 Parser step initial extract
1175
1175
@@ -1272,7 +1272,7 @@ splitSome (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
1272-- /Pre-release/
1272-- /Pre-release/
1273--
1273--
1274{-# INLINE_NORMAL die #-}
1274{-# INLINE_NORMAL die #-}
1275−die :: Monad m => String -> Parser m a b
1275+die :: Monad m => String -> Parser a m b
1276die err = Parser undefined (pure (IError err)) undefined
1276die err = Parser undefined (pure (IError err)) undefined
1277
1277
1278-- | See 'Streamly.Internal.Data.Parser.dieM'.
1278-- | See 'Streamly.Internal.Data.Parser.dieM'.
@@ -1280,7 +1280,7 @@ die err = Parser undefined (pure (IError err)) undefined
1280-- /Pre-release/
1280-- /Pre-release/
1281--
1281--
1282{-# INLINE dieM #-}
1282{-# INLINE dieM #-}
1283−dieM :: Monad m => m String -> Parser m a b
1283+dieM :: Monad m => m String -> Parser a m b
1284dieM err = Parser undefined (IError <$> err) undefined
1284dieM err = Parser undefined (IError <$> err) undefined
1285
1285
1286-- Note: The default implementations of "some" and "many" loop infinitely
1286-- Note: The default implementations of "some" and "many" loop infinitely
@@ -1299,7 +1299,7 @@ dieM err = Parser undefined (IError <$> err) undefined
1299-- >>> Stream.parse (Parser.satisfy (> 0) <|> undefined) $ Stream.fromList [1..10]
1299-- >>> Stream.parse (Parser.satisfy (> 0) <|> undefined) $ Stream.fromList [1..10]
1300-- 1
1300-- 1
1301--
1301--
1302−instance Monad m => Alternative (Parser m a) where
1302+instance Monad m => Alternative (Parser a m) where
1303 {-# INLINE empty #-}
1303 {-# INLINE empty #-}
1304 empty = die "empty"
1304 empty = die "empty"
1305
1305
@@ -1323,7 +1323,7 @@ data ConcatParseState sl m a b =
1323--
1323--
1324{-# INLINE concatMap #-}
1324{-# INLINE concatMap #-}
1325concatMap :: Monad m =>
1325concatMap :: Monad m =>
1326− (b -> Parser m a c) -> Parser m a b -> Parser m a c
1326+ (b -> Parser a m c) -> Parser a m b -> Parser a m c
1327concatMap func (Parser stepL initialL extractL) = Parser step initial extract
1327concatMap func (Parser stepL initialL extractL) = Parser step initial extract
1328
1328
1329 where
1329 where
@@ -1390,7 +1390,7 @@ concatMap func (Parser stepL initialL extractL) = Parser step initial extract
1390
1390
1391{-# INLINE noErrorUnsafeConcatMap #-}
1391{-# INLINE noErrorUnsafeConcatMap #-}
1392noErrorUnsafeConcatMap :: Monad m =>
1392noErrorUnsafeConcatMap :: Monad m =>
1393− (b -> Parser m a c) -> Parser m a b -> Parser m a c
1393+ (b -> Parser a m c) -> Parser a m b -> Parser a m c
1394noErrorUnsafeConcatMap func (Parser stepL initialL extractL) =
1394noErrorUnsafeConcatMap func (Parser stepL initialL extractL) =
1395 Parser step initial extract
1395 Parser step initial extract
1396
1396
@@ -1462,7 +1462,7 @@ noErrorUnsafeConcatMap func (Parser stepL initialL extractL) =
1462
1462
1463-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
1463-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
1464--
1464--
1465−instance Monad m => Monad (Parser m a) where
1465+instance Monad m => Monad (Parser a m) where
1466 {-# INLINE return #-}
1466 {-# INLINE return #-}
1467 return = pure
1467 return = pure
1468
1468
@@ -1474,14 +1474,14 @@ instance Monad m => Monad (Parser m a) where
1474
1474
1475-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
1475-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
1476--
1476--
1477−instance Monad m => MonadPlus (Parser m a) where
1477+instance Monad m => MonadPlus (Parser a m) where
1478 {-# INLINE mzero #-}
1478 {-# INLINE mzero #-}
1479 mzero = die "mzero"
1479 mzero = die "mzero"
1480
1480
1481 {-# INLINE mplus #-}
1481 {-# INLINE mplus #-}
1482 mplus = alt
1482 mplus = alt
1483
1483
1484−instance (Monad m, MonadReader r m) => MonadReader r (Parser m a) where
1484+instance (Monad m, MonadReader r m) => MonadReader r (Parser a m) where
1485 {-# INLINE ask #-}
1485 {-# INLINE ask #-}
1486 ask = fromEffect ask
1486 ask = fromEffect ask
1487
1487
@@ -1491,14 +1491,14 @@ instance (Monad m, MonadReader r m) => MonadReader r (Parser m a) where
1491 (local f init')
1491 (local f init')
1492 (local f . extract)
1492 (local f . extract)
1493
1493
1494−instance (Monad m, MonadState s m) => MonadState s (Parser m a) where
1494+instance (Monad m, MonadState s m) => MonadState s (Parser a m) where
1495 {-# INLINE get #-}
1495 {-# INLINE get #-}
1496 get = fromEffect get
1496 get = fromEffect get
1497
1497
1498 {-# INLINE put #-}
1498 {-# INLINE put #-}
1499 put = fromEffect . put
1499 put = fromEffect . put
1500
1500
1501−instance (Monad m, MonadIO m) => MonadIO (Parser m a) where
1501+instance (Monad m, MonadIO m) => MonadIO (Parser a m) where
1502 {-# INLINE liftIO #-}
1502 {-# INLINE liftIO #-}
1503 liftIO = fromEffect . liftIO
1503 liftIO = fromEffect . liftIO
1504
1504
@@ -1507,7 +1507,7 @@ instance (Monad m, MonadIO m) => MonadIO (Parser m a) where
1507------------------------------------------------------------------------------
1507------------------------------------------------------------------------------
1508
1508
1509{-# INLINE lmap #-}
1509{-# INLINE lmap #-}
1510−lmap :: (a -> b) -> Parser m b r -> Parser m a r
1510+lmap :: (a -> b) -> Parser b m r -> Parser a m r
1511lmap f (Parser step begin done) = Parser step1 begin done
1511lmap f (Parser step begin done) = Parser step1 begin done
1512
1512
1513 where
1513 where
@@ -1515,7 +1515,7 @@ lmap f (Parser step begin done) = Parser step1 begin done
1515 step1 x a = step x (f a)
1515 step1 x a = step x (f a)
1516
1516
1517{-# INLINE lmapM #-}
1517{-# INLINE lmapM #-}
1518−lmapM :: Monad m => (a -> m b) -> Parser m b r -> Parser m a r
1518+lmapM :: Monad m => (a -> m b) -> Parser b m r -> Parser a m r
1519lmapM f (Parser step begin done) = Parser step1 begin done
1519lmapM f (Parser step begin done) = Parser step1 begin done
1520
1520
1521 where
1521 where
@@ -1523,7 +1523,7 @@ lmapM f (Parser step begin done) = Parser step1 begin done
1523 step1 x a = f a >>= step x
1523 step1 x a = f a >>= step x
1524
1524
1525{-# INLINE filter #-}
1525{-# INLINE filter #-}
1526−filter :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
1526+filter :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
1527filter f (Parser step initial extract) = Parser step1 initial extract
1527filter f (Parser step initial extract) = Parser step1 initial extract
1528
1528
1529 where
1529 where
core/src/Streamly/Internal/Data/Parser/ParserK/Type.hs+15−15
@@ -82,7 +82,7 @@ instance Functor Parse where
82-- input without a result or return a result with no further input to be
82-- input without a result or return a result with no further input to be
83-- consumed.
83-- consumed.
84--
84--
85−newtype Parser m a b = MkParser
85+newtype Parser a m b = MkParser
86 { runParser :: forall r.
86 { runParser :: forall r.
87 -- leftover: the number of elements that were not used by the
87 -- leftover: the number of elements that were not used by the
88 -- previous consumer and should be carried forward.
88 -- previous consumer and should be carried forward.
@@ -111,7 +111,7 @@ newtype Parser m a b = MkParser
111-- XXX rewrite this using ParserD, expose rmapM from ParserD.
111-- XXX rewrite this using ParserD, expose rmapM from ParserD.
112-- | Maps a function over the output of the parser.
112-- | Maps a function over the output of the parser.
113--
113--
114−instance Functor m => Functor (Parser m a) where
114+instance Functor m => Functor (Parser a m) where
115 {-# INLINE fmap #-}
115 {-# INLINE fmap #-}
116 fmap f parser = MkParser $ \n st k ->
116 fmap f parser = MkParser $ \n st k ->
117 let k1 s res = k s (fmap f res)
117 let k1 s res = k s (fmap f res)
@@ -128,7 +128,7 @@ instance Functor m => Functor (Parser m a) where
128-- /Pre-release/
128-- /Pre-release/
129--
129--
130{-# INLINE fromPure #-}
130{-# INLINE fromPure #-}
131−fromPure :: b -> Parser m a b
131+fromPure :: b -> Parser a m b
132fromPure b = MkParser $ \n st k -> k st (Success n b)
132fromPure b = MkParser $ \n st k -> k st (Success n b)
133
133
134-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
134-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
@@ -136,14 +136,14 @@ fromPure b = MkParser $ \n st k -> k st (Success n b)
136-- /Pre-release/
136-- /Pre-release/
137--
137--
138{-# INLINE fromEffect #-}
138{-# INLINE fromEffect #-}
139−fromEffect :: Monad m => m b -> Parser m a b
139+fromEffect :: Monad m => m b -> Parser a m b
140fromEffect eff = MkParser $ \n st k -> eff >>= \b -> k st (Success n b)
140fromEffect eff = MkParser $ \n st k -> eff >>= \b -> k st (Success n b)
141
141
142-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.serialWith'. Note that
142-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.serialWith'. Note that
143-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.serialWith'
143-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.serialWith'
144-- when fusion is important.
144-- when fusion is important.
145--
145--
146−instance Monad m => Applicative (Parser m a) where
146+instance Monad m => Applicative (Parser a m) where
147 {-# INLINE pure #-}
147 {-# INLINE pure #-}
148 pure = fromPure
148 pure = fromPure
149
149
@@ -180,7 +180,7 @@ instance Monad m => Applicative (Parser m a) where
180-- /Pre-release/
180-- /Pre-release/
181--
181--
182{-# INLINE die #-}
182{-# INLINE die #-}
183−die :: String -> Parser m a b
183+die :: String -> Parser a m b
184die err = MkParser (\_ st k -> k st (Failure err))
184die err = MkParser (\_ st k -> k st (Failure err))
185
185
186-- | Monad composition can be used for lookbehind parsers, we can make the
186-- | Monad composition can be used for lookbehind parsers, we can make the
@@ -190,7 +190,7 @@ die err = MkParser (\_ st k -> k st (Failure err))
190-- following parser:
190-- following parser:
191--
191--
192-- @
192-- @
193−-- backtracking :: MonadCatch m => PR.Parser m Char String
193+-- backtracking :: MonadCatch m => PR.Parser Char m String
194-- backtracking =
194-- backtracking =
195-- sequence [PR.satisfy isDigit, PR.satisfy isAlpha]
195-- sequence [PR.satisfy isDigit, PR.satisfy isAlpha]
196-- '<|>'
196-- '<|>'
@@ -206,7 +206,7 @@ die err = MkParser (\_ st k -> k st (Failure err))
206-- @
206-- @
207-- data DigitOrAlpha = Digit Char | Alpha Char
207-- data DigitOrAlpha = Digit Char | Alpha Char
208--
208--
209−-- lookbehind :: MonadCatch m => PR.Parser m Char String
209+-- lookbehind :: MonadCatch m => PR.Parser Char m String
210-- lookbehind = do
210-- lookbehind = do
211-- x1 \<- Digit '<$>' PR.satisfy isDigit
211-- x1 \<- Digit '<$>' PR.satisfy isDigit
212-- '<|>' Alpha '<$>' PR.satisfy isAlpha
212-- '<|>' Alpha '<$>' PR.satisfy isAlpha
@@ -225,7 +225,7 @@ die err = MkParser (\_ st k -> k st (Failure err))
225-- does not fuse, use 'Streamly.Internal.Data.Parser.concatMap' when you need
225-- does not fuse, use 'Streamly.Internal.Data.Parser.concatMap' when you need
226-- fusion.
226-- fusion.
227--
227--
228−instance Monad m => Monad (Parser m a) where
228+instance Monad m => Monad (Parser a m) where
229 {-# INLINE return #-}
229 {-# INLINE return #-}
230 return = pure
230 return = pure
231
231
@@ -244,12 +244,12 @@ instance Monad m => Monad (Parser m a) where
244 {-# INLINE fail #-}
244 {-# INLINE fail #-}
245 fail = die
245 fail = die
246#endif
246#endif
247−instance Monad m => Fail.MonadFail (Parser m a) where
247+instance Monad m => Fail.MonadFail (Parser a m) where
248 {-# INLINE fail #-}
248 {-# INLINE fail #-}
249 fail = die
249 fail = die
250
250
251instance (MonadThrow m, MonadReader r m, MonadCatch m) =>
251instance (MonadThrow m, MonadReader r m, MonadCatch m) =>
252− MonadReader r (Parser m a) where
252+ MonadReader r (Parser a m) where
253
253
254 {-# INLINE ask #-}
254 {-# INLINE ask #-}
255 ask = fromEffect ask
255 ask = fromEffect ask
@@ -257,14 +257,14 @@ instance (MonadThrow m, MonadReader r m, MonadCatch m) =>
257 {-# INLINE local #-}
257 {-# INLINE local #-}
258 local f p = MkParser $ \n st k -> local f $ runParser p n st k
258 local f p = MkParser $ \n st k -> local f $ runParser p n st k
259
259
260−instance (MonadThrow m, MonadState s m) => MonadState s (Parser m a) where
260+instance (MonadThrow m, MonadState s m) => MonadState s (Parser a m) where
261 {-# INLINE get #-}
261 {-# INLINE get #-}
262 get = fromEffect get
262 get = fromEffect get
263
263
264 {-# INLINE put #-}
264 {-# INLINE put #-}
265 put = fromEffect . put
265 put = fromEffect . put
266
266
267−instance (MonadThrow m, MonadIO m) => MonadIO (Parser m a) where
267+instance (MonadThrow m, MonadIO m) => MonadIO (Parser a m) where
268 {-# INLINE liftIO #-}
268 {-# INLINE liftIO #-}
269 liftIO = fromEffect . liftIO
269 liftIO = fromEffect . liftIO
270
270
@@ -285,7 +285,7 @@ instance (MonadThrow m, MonadIO m) => MonadIO (Parser m a) where
285-- does not fuse, use 'Streamly.Internal.Data.Parser.alt' when you need
285-- does not fuse, use 'Streamly.Internal.Data.Parser.alt' when you need
286-- fusion.
286-- fusion.
287--
287--
288−instance Monad m => Alternative (Parser m a) where
288+instance Monad m => Alternative (Parser a m) where
289 {-# INLINE empty #-}
289 {-# INLINE empty #-}
290 empty = die "empty"
290 empty = die "empty"
291
291
@@ -318,7 +318,7 @@ instance Monad m => Alternative (Parser m a) where
318-- | 'mzero' is same as 'empty', it aborts the parser. 'mplus' is same as
318-- | 'mzero' is same as 'empty', it aborts the parser. 'mplus' is same as
319-- '<|>', it selects the first succeeding parser.
319-- '<|>', it selects the first succeeding parser.
320--
320--
321−instance Monad m => MonadPlus (Parser m a) where
321+instance Monad m => MonadPlus (Parser a m) where
322 {-# INLINE mzero #-}
322 {-# INLINE mzero #-}
323 mzero = die "mzero"
323 mzero = die "mzero"
324
324
core/src/Streamly/Internal/Data/Producer/Source.hs+4−4
@@ -113,7 +113,7 @@ newtype List a = List {getList :: [a]}
113{-# INLINE_NORMAL parseD #-}
113{-# INLINE_NORMAL parseD #-}
114parseD
114parseD
115 :: MonadThrow m
115 :: MonadThrow m
116− => ParserD.Parser m a b
116+ => ParserD.Parser a m b
117 -> Producer m (Source s a) a
117 -> Producer m (Source s a) a
118 -> Source s a
118 -> Source s a
119 -> m (b, Source s a)
119 -> m (b, Source s a)
@@ -243,7 +243,7 @@ parseD
243{-# INLINE [3] parse #-}
243{-# INLINE [3] parse #-}
244parse
244parse
245 :: MonadThrow m
245 :: MonadThrow m
246− => ParserK.Parser m a b
246+ => ParserK.Parser a m b
247 -> Producer m (Source s a) a
247 -> Producer m (Source s a) a
248 -> Source s a
248 -> Source s a
249 -> m (b, Source s a)
249 -> m (b, Source s a)
@@ -255,7 +255,7 @@ parse = parseD . ParserD.fromParserK
255
255
256{-# INLINE parseManyD #-}
256{-# INLINE parseManyD #-}
257parseManyD :: MonadThrow m =>
257parseManyD :: MonadThrow m =>
258− ParserD.Parser m a b
258+ ParserD.Parser a m b
259 -> Producer m (Source x a) a
259 -> Producer m (Source x a) a
260 -> Producer m (Source x a) b
260 -> Producer m (Source x a) b
261parseManyD parser reader = Producer step return return
261parseManyD parser reader = Producer step return return
@@ -276,7 +276,7 @@ parseManyD parser reader = Producer step return return
276-- /Pre-release/
276-- /Pre-release/
277{-# INLINE parseMany #-}
277{-# INLINE parseMany #-}
278parseMany :: MonadThrow m =>
278parseMany :: MonadThrow m =>
279− ParserK.Parser m a b
279+ ParserK.Parser a m b
280 -> Producer m (Source x a) a
280 -> Producer m (Source x a) a
281 -> Producer m (Source x a) b
281 -> Producer m (Source x a) b
282parseMany parser = parseManyD (ParserD.fromParserK parser)
282parseMany parser = parseManyD (ParserD.fromParserK parser)
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+5−5
@@ -230,7 +230,7 @@ foldlT f z s = D.foldlT f z (toStreamD s)
230-- /Internal/
230-- /Internal/
231--
231--
232{-# INLINE_NORMAL parseD #-}
232{-# INLINE_NORMAL parseD #-}
233−parseD :: MonadThrow m => PRD.Parser m a b -> Stream m a -> m b
233+parseD :: MonadThrow m => PRD.Parser a m b -> Stream m a -> m b
234parseD p = D.parse p . toStreamD
234parseD p = D.parse p . toStreamD
235
235
236-- XXX Drive directly as parserK rather than converting to parserD first.
236-- XXX Drive directly as parserK rather than converting to parserD first.
@@ -239,7 +239,7 @@ parseD p = D.parse p . toStreamD
239--
239--
240-- /Internal/
240-- /Internal/
241{-# INLINE parseK #-}
241{-# INLINE parseK #-}
242−parseK :: MonadThrow m => PRK.Parser m a b -> Stream m a -> m b
242+parseK :: MonadThrow m => PRK.Parser a m b -> Stream m a -> m b
243parseK = parse
243parseK = parse
244
244
245-- | Parse a stream using the supplied 'Parser'.
245-- | Parse a stream using the supplied 'Parser'.
@@ -255,12 +255,12 @@ parseK = parse
255-- Note: @parse p@ is not the same as @head . parseMany p@ on an empty stream.
255-- Note: @parse p@ is not the same as @head . parseMany p@ on an empty stream.
256--
256--
257{-# INLINE [3] parse #-}
257{-# INLINE [3] parse #-}
258−parse :: MonadThrow m => Parser m a b -> Stream m a -> m b
258+parse :: MonadThrow m => Parser a m b -> Stream m a -> m b
259parse = parseD . PRD.fromParserK
259parse = parseD . PRD.fromParserK
260
260
261{-# INLINE_NORMAL parseBreakD #-}
261{-# INLINE_NORMAL parseBreakD #-}
262parseBreakD :: MonadThrow m =>
262parseBreakD :: MonadThrow m =>
263− PRD.Parser m a b -> Stream m a -> m (b, Stream m a)
263+ PRD.Parser a m b -> Stream m a -> m (b, Stream m a)
264parseBreakD parser strm = do
264parseBreakD parser strm = do
265 (b, strmD) <- D.parseBreak parser (toStreamD strm)
265 (b, strmD) <- D.parseBreak parser (toStreamD strm)
266 return $! (b, fromStreamD strmD)
266 return $! (b, fromStreamD strmD)
@@ -270,7 +270,7 @@ parseBreakD parser strm = do
270-- /Not fused/
270-- /Not fused/
271--
271--
272{-# INLINE parseBreak #-}
272{-# INLINE parseBreak #-}
273−parseBreak :: MonadThrow m => Parser m a b -> Stream m a -> m (b, Stream m a)
273+parseBreak :: MonadThrow m => Parser a m b -> Stream m a -> m (b, Stream m a)
274parseBreak p strm = fmap f $ K.parseBreak (PRD.fromParserK p) (toStreamK strm)
274parseBreak p strm = fmap f $ K.parseBreak (PRD.fromParserK p) (toStreamK strm)
275
275
276 where
276 where
core/src/Streamly/Internal/Data/Stream/Reduce.hs+7−7
@@ -22,7 +22,7 @@ module Streamly.Internal.Data.Stream.Reduce
22 --
22 --
23 -- @
23 -- @
24 -- f (Fold m a b) -> Stream m a -> Stream m b
24 -- f (Fold m a b) -> Stream m a -> Stream m b
25− -- f (Parser m a b) -> Stream m a -> Stream m b
25+ -- f (Parser a m b) -> Stream m a -> Stream m b
26 -- @
26 -- @
27
27
28 -- ** Generic Folding
28 -- ** Generic Folding
@@ -339,7 +339,7 @@ splitOnAny _subseq _f _m =
339{-# INLINE parseMany #-}
339{-# INLINE parseMany #-}
340parseMany
340parseMany
341 :: MonadThrow m
341 :: MonadThrow m
342− => Parser m a b
342+ => Parser a m b
343 -> Stream m a
343 -> Stream m a
344 -> Stream m b
344 -> Stream m b
345parseMany p m =
345parseMany p m =
@@ -352,7 +352,7 @@ parseMany p m =
352{-# INLINE parseManyD #-}
352{-# INLINE parseManyD #-}
353parseManyD
353parseManyD
354 :: MonadThrow m
354 :: MonadThrow m
355− => ParserD.Parser m a b
355+ => ParserD.Parser a m b
356 -> Stream m a
356 -> Stream m a
357 -> Stream m b
357 -> Stream m b
358parseManyD p m =
358parseManyD p m =
@@ -366,7 +366,7 @@ parseManyD p m =
366{-# INLINE parseSequence #-}
366{-# INLINE parseSequence #-}
367parseSequence
367parseSequence
368 :: -- Monad m =>
368 :: -- Monad m =>
369− Stream m (Parser m a b)
369+ Stream m (Parser a m b)
370 -> Stream m a
370 -> Stream m a
371 -> Stream m b
371 -> Stream m b
372parseSequence _f _m = undefined
372parseSequence _f _m = undefined
@@ -384,8 +384,8 @@ parseSequence _f _m = undefined
384{-# INLINE parseManyTill #-}
384{-# INLINE parseManyTill #-}
385parseManyTill ::
385parseManyTill ::
386 -- MonadThrow m =>
386 -- MonadThrow m =>
387− Parser m a b
387+ Parser a m b
388− -> Parser m a x
388+ -> Parser a m x
389 -> t m a
389 -> t m a
390 -> t m b
390 -> t m b
391parseManyTill = undefined
391parseManyTill = undefined
@@ -407,7 +407,7 @@ parseManyTill = undefined
407{-# INLINE parseIterate #-}
407{-# INLINE parseIterate #-}
408parseIterate
408parseIterate
409 :: MonadThrow m
409 :: MonadThrow m
410− => (b -> Parser m a b)
410+ => (b -> Parser a m b)
411 -> b
411 -> b
412 -> Stream m a
412 -> Stream m a
413 -> Stream m b
413 -> Stream m b
core/src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs+2−2
@@ -142,7 +142,7 @@ newtype List a = List {getList :: [a]}
142{-# INLINE_NORMAL parse #-}
142{-# INLINE_NORMAL parse #-}
143parse
143parse
144 :: MonadThrow m
144 :: MonadThrow m
145− => PRD.Parser m a b
145+ => PRD.Parser a m b
146 -> Stream m a
146 -> Stream m a
147 -> m b
147 -> m b
148parse parser strm = do
148parse parser strm = do
@@ -153,7 +153,7 @@ parse parser strm = do
153{-# INLINE_NORMAL parseBreak #-}
153{-# INLINE_NORMAL parseBreak #-}
154parseBreak
154parseBreak
155 :: MonadThrow m
155 :: MonadThrow m
156− => PRD.Parser m a b
156+ => PRD.Parser a m b
157 -> Stream m a
157 -> Stream m a
158 -> m (b, Stream m a)
158 -> m (b, Stream m a)
159parseBreak (PRD.Parser pstep initial extract) stream@(Stream step state) = do
159parseBreak (PRD.Parser pstep initial extract) stream@(Stream step state) = do
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+3−3
@@ -106,7 +106,7 @@ module Streamly.Internal.Data.Stream.StreamD.Nesting
106 --
106 --
107 -- @
107 -- @
108 -- f (Fold m a b) -> t m a -> t m b
108 -- f (Fold m a b) -> t m a -> t m b
109− -- f (Parser m a b) -> t m a -> t m b
109+ -- f (Parser a m b) -> t m a -> t m b
110 -- @
110 -- @
111
111
112 -- ** Folding
112 -- ** Folding
@@ -1152,7 +1152,7 @@ data ParseChunksState x inpBuf st pst =
1152{-# INLINE_NORMAL parseMany #-}
1152{-# INLINE_NORMAL parseMany #-}
1153parseMany
1153parseMany
1154 :: MonadThrow m
1154 :: MonadThrow m
1155− => PRD.Parser m a b
1155+ => PRD.Parser a m b
1156 -> Stream m a
1156 -> Stream m a
1157 -> Stream m b
1157 -> Stream m b
1158parseMany (PRD.Parser pstep initial extract) (Stream step state) =
1158parseMany (PRD.Parser pstep initial extract) (Stream step state) =
@@ -1338,7 +1338,7 @@ data ConcatParseState b inpBuf st p m a =
1338{-# INLINE_NORMAL parseIterate #-}
1338{-# INLINE_NORMAL parseIterate #-}
1339parseIterate
1339parseIterate
1340 :: MonadThrow m
1340 :: MonadThrow m
1341− => (b -> PRD.Parser m a b)
1341+ => (b -> PRD.Parser a m b)
1342 -> b
1342 -> b
1343 -> Stream m a
1343 -> Stream m a
1344 -> Stream m b
1344 -> Stream m b
core/src/Streamly/Internal/Data/Stream/StreamK.hs+1−1
@@ -1025,7 +1025,7 @@ splitAt n ls
1025{-# INLINE_NORMAL parseBreak #-}
1025{-# INLINE_NORMAL parseBreak #-}
1026parseBreak
1026parseBreak
1027 :: MonadThrow m
1027 :: MonadThrow m
1028− => PR.Parser m a b
1028+ => PR.Parser a m b
1029 -> Stream m a
1029 -> Stream m a
1030 -> m (b, Stream m a)
1030 -> m (b, Stream m a)
1031parseBreak (PR.Parser pstep initial extract) stream = do
1031parseBreak (PR.Parser pstep initial extract) stream = do
core/src/Streamly/Internal/Unicode/Char/Parser.hs+11−11
@@ -78,7 +78,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
78-- We can measure if there is a signficant difference and if so we can add such
79-- predicates to Streamly.Unicode.Parser.Latin1.
79-- predicates to Streamly.Unicode.Parser.Latin1.
80--
80--
81−#define CHAR_PARSER_SIG(NAME) NAME :: MonadCatch m => Parser m Char Char
81+#define CHAR_PARSER_SIG(NAME) NAME :: MonadCatch m => Parser Char m Char
82-- XXX Need to use the predicates from Unicode.Char module/unicode-data package
82-- XXX Need to use the predicates from Unicode.Char module/unicode-data package
83#define CHAR_PARSER(NAME, PREDICATE) NAME = Parser.satisfy Char.PREDICATE
83#define CHAR_PARSER(NAME, PREDICATE) NAME = Parser.satisfy Char.PREDICATE
84#define CHAR_PARSER_DOC(PREDICATE) -- | Match any character that satisfies 'Char.PREDICATE'
84#define CHAR_PARSER_DOC(PREDICATE) -- | Match any character that satisfies 'Char.PREDICATE'
@@ -168,13 +168,13 @@ CHAR_PARSER(asciiLower,isAsciiLower)
168
168
169-- | Match a specific character.
169-- | Match a specific character.
170{-# INLINE char #-}
170{-# INLINE char #-}
171−char :: MonadCatch m => Char -> Parser m Char Char
171+char :: MonadCatch m => Char -> Parser Char m Char
172char c = Parser.satisfy (== c)
172char c = Parser.satisfy (== c)
173
173
174-- XXX Case conversion may lead to change in number of chars
174-- XXX Case conversion may lead to change in number of chars
175-- | Match a specific character ignoring case.
175-- | Match a specific character ignoring case.
176{-# INLINE charIgnoreCase #-}
176{-# INLINE charIgnoreCase #-}
177−charIgnoreCase :: MonadCatch m => Char -> Parser m Char Char
177+charIgnoreCase :: MonadCatch m => Char -> Parser Char m Char
178charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
178charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
179
179
180--------------------------------------------------------------------------------
180--------------------------------------------------------------------------------
@@ -182,21 +182,21 @@ charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
182--------------------------------------------------------------------------------
182--------------------------------------------------------------------------------
183
183
184-- | Match the input with the supplied string and return it if successful.
184-- | Match the input with the supplied string and return it if successful.
185−string :: MonadCatch m => String -> Parser m Char String
185+string :: MonadCatch m => String -> Parser Char m String
186string = Parser.listEq
186string = Parser.listEq
187
187
188-- XXX Not accurate unicode case conversion
188-- XXX Not accurate unicode case conversion
189-- | Match the input with the supplied string and return it if successful.
189-- | Match the input with the supplied string and return it if successful.
190−stringIgnoreCase :: MonadCatch m => String -> Parser m Char String
190+stringIgnoreCase :: MonadCatch m => String -> Parser Char m String
191stringIgnoreCase s =
191stringIgnoreCase s =
192 Parser.lmap Char.toLower (Parser.listEq (map Char.toLower s))
192 Parser.lmap Char.toLower (Parser.listEq (map Char.toLower s))
193
193
194-- | Drop /zero/ or more white space characters.
194-- | Drop /zero/ or more white space characters.
195−dropSpace :: MonadCatch m => Parser m Char ()
195+dropSpace :: MonadCatch m => Parser Char m ()
196dropSpace = Parser.dropWhile Char.isSpace
196dropSpace = Parser.dropWhile Char.isSpace
197
197
198-- | Drop /one/ or more white space characters.
198-- | Drop /one/ or more white space characters.
199−dropSpace1 :: MonadCatch m => Parser m Char ()
199+dropSpace1 :: MonadCatch m => Parser Char m ()
200dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
200dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
201
201
202--------------------------------------------------------------------------------
202--------------------------------------------------------------------------------
@@ -207,7 +207,7 @@ dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
207--
207--
208-- | Parse and decode an unsigned integral decimal number.
208-- | Parse and decode an unsigned integral decimal number.
209{-# INLINE decimal #-}
209{-# INLINE decimal #-}
210−decimal :: (MonadCatch m, Integral a) => Parser m Char a
210+decimal :: (MonadCatch m, Integral a) => Parser Char m a
211decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
211decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
212
212
213 where
213 where
@@ -219,7 +219,7 @@ decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
219--
219--
220-- Note: This parser does not accept a leading @\"0x\"@ string.
220-- Note: This parser does not accept a leading @\"0x\"@ string.
221{-# INLINE hexadecimal #-}
221{-# INLINE hexadecimal #-}
222−hexadecimal :: (MonadCatch m, Integral a, Bits a) => Parser m Char a
222+hexadecimal :: (MonadCatch m, Integral a, Bits a) => Parser Char m a
223hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
223hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
224
224
225 where
225 where
@@ -244,7 +244,7 @@ hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
244-- | Allow an optional leading @\'+\'@ or @\'-\'@ sign character before any
244-- | Allow an optional leading @\'+\'@ or @\'-\'@ sign character before any
245-- parser.
245-- parser.
246{-# INLINE signed #-}
246{-# INLINE signed #-}
247−signed :: (Num a, MonadCatch m) => Parser m Char a -> Parser m Char a
247+signed :: (Num a, MonadCatch m) => Parser Char m a -> Parser Char m a
248signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
248signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
249
249
250-- | Parse a 'Double'.
250-- | Parse a 'Double'.
@@ -278,5 +278,5 @@ signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
278-- \"Infinity\".
278-- \"Infinity\".
279--
279--
280-- /Unimplemented/
280-- /Unimplemented/
281−double :: Parser m Char Double
281+double :: Parser Char m Double
282double = undefined
282double = undefined
core/src/Streamly/Internal/Unicode/Stream.hs+2−2
@@ -453,7 +453,7 @@ data UTF8CharDecodeState a
453
453
454{-# INLINE parseCharUtf8WithD #-}
454{-# INLINE parseCharUtf8WithD #-}
455parseCharUtf8WithD ::
455parseCharUtf8WithD ::
456− MonadThrow m => CodingFailureMode -> ParserD.Parser m Word8 Char
456+ MonadThrow m => CodingFailureMode -> ParserD.Parser Word8 m Char
457parseCharUtf8WithD cfm = ParserD.Parser (step' utf8d) initial extract
457parseCharUtf8WithD cfm = ParserD.Parser (step' utf8d) initial extract
458
458
459 where
459 where
@@ -541,7 +541,7 @@ writeCharUtf8' = ParserD.toFold (parseCharUtf8WithD ErrorOnCodingFailure)
541-- This needs to be investigated futher.
541-- This needs to be investigated futher.
542{-# INLINE parseCharUtf8With #-}
542{-# INLINE parseCharUtf8With #-}
543parseCharUtf8With ::
543parseCharUtf8With ::
544− MonadCatch m => CodingFailureMode -> Parser.Parser m Word8 Char
544+ MonadCatch m => CodingFailureMode -> Parser.Parser Word8 m Char
545parseCharUtf8With = ParserD.toParserK . parseCharUtf8WithD
545parseCharUtf8With = ParserD.toParserK . parseCharUtf8WithD
546
546
547-- XXX write it as a parser and use parseMany to decode a stream, need to check
547-- XXX write it as a parser and use parseMany to decode a stream, need to check
core/src/Streamly/Internal/Unicode/String.hs+2−2
@@ -61,12 +61,12 @@ data StrSegment
61 | StrVar String
61 | StrVar String
62 deriving (Show, Eq)
62 deriving (Show, Eq)
63
63
64−haskellIdentifier :: MonadCatch m => Parser m Char String
64+haskellIdentifier :: MonadCatch m => Parser Char m String
65haskellIdentifier =
65haskellIdentifier =
66 let p = Parser.alphaNum <|> Parser.char '\'' <|> Parser.char '_'
66 let p = Parser.alphaNum <|> Parser.char '\'' <|> Parser.char '_'
67 in Parser.some p Fold.toList
67 in Parser.some p Fold.toList
68
68
69−strParser :: MonadCatch m => Parser m Char [StrSegment]
69+strParser :: MonadCatch m => Parser Char m [StrSegment]
70strParser = Parser.many content Fold.toList
70strParser = Parser.many content Fold.toList
71
71
72 where
72 where
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+7−7
@@ -24,7 +24,7 @@ module Streamly.Internal.Data.Stream.IsStream.Reduce {-# DEPRECATED "Please use
24 --
24 --
25 -- @
25 -- @
26 -- f (Fold m a b) -> t m a -> t m b
26 -- f (Fold m a b) -> t m a -> t m b
27− -- f (Parser m a b) -> t m a -> t m b
27+ -- f (Parser a m b) -> t m a -> t m b
28 -- @
28 -- @
29
29
30 -- ** Generic Folding
30 -- ** Generic Folding
@@ -383,7 +383,7 @@ refoldIterateM c i m = fromStreamD $ D.refoldIterateM c i (toStreamD m)
383{-# INLINE parseMany #-}
383{-# INLINE parseMany #-}
384parseMany
384parseMany
385 :: (IsStream t, MonadThrow m)
385 :: (IsStream t, MonadThrow m)
386− => Parser m a b
386+ => Parser a m b
387 -> t m a
387 -> t m a
388 -> t m b
388 -> t m b
389parseMany p m =
389parseMany p m =
@@ -396,7 +396,7 @@ parseMany p m =
396{-# INLINE parseManyD #-}
396{-# INLINE parseManyD #-}
397parseManyD
397parseManyD
398 :: (IsStream t, MonadThrow m)
398 :: (IsStream t, MonadThrow m)
399− => PRD.Parser m a b
399+ => PRD.Parser a m b
400 -> t m a
400 -> t m a
401 -> t m b
401 -> t m b
402parseManyD p m =
402parseManyD p m =
@@ -410,7 +410,7 @@ parseManyD p m =
410{-# INLINE parseSequence #-}
410{-# INLINE parseSequence #-}
411parseSequence
411parseSequence
412 :: -- (IsStream t, Monad m) =>
412 :: -- (IsStream t, Monad m) =>
413− t m (Parser m a b)
413+ t m (Parser a m b)
414 -> t m a
414 -> t m a
415 -> t m b
415 -> t m b
416parseSequence _f _m = undefined
416parseSequence _f _m = undefined
@@ -428,8 +428,8 @@ parseSequence _f _m = undefined
428{-# INLINE parseManyTill #-}
428{-# INLINE parseManyTill #-}
429parseManyTill ::
429parseManyTill ::
430 -- (IsStream t, MonadThrow m) =>
430 -- (IsStream t, MonadThrow m) =>
431− Parser m a b
431+ Parser a m b
432− -> Parser m a x
432+ -> Parser a m x
433 -> t m a
433 -> t m a
434 -> t m b
434 -> t m b
435parseManyTill = undefined
435parseManyTill = undefined
@@ -450,7 +450,7 @@ parseManyTill = undefined
450{-# INLINE parseIterate #-}
450{-# INLINE parseIterate #-}
451parseIterate
451parseIterate
452 :: (IsStream t, MonadThrow m)
452 :: (IsStream t, MonadThrow m)
453− => (b -> Parser m a b)
453+ => (b -> Parser a m b)
454 -> b
454 -> b
455 -> t m a
455 -> t m a
456 -> t m b
456 -> t m b
src/Streamly/Internal/FileSystem/Event/Darwin.hs+1−1
@@ -489,7 +489,7 @@ data Event = Event
489-- XXX should we use a magic in the header to avoid any issues due to
489-- XXX should we use a magic in the header to avoid any issues due to
490-- misalignment of records? Can that ever happen?
490-- misalignment of records? Can that ever happen?
491--
491--
492−readOneEvent :: Parser IO Word8 Event
492+readOneEvent :: Parser Word8 IO Event
493readOneEvent = do
493readOneEvent = do
494 arr <- PR.takeEQ 24 (A.writeN 24)
494 arr <- PR.takeEQ 24 (A.writeN 24)
495 let arr1 = A.castUnsafe arr :: Array Word64
495 let arr1 = A.castUnsafe arr :: Array Word64
src/Streamly/Internal/FileSystem/Event/Linux.hs+1−1
@@ -799,7 +799,7 @@ data Event = Event
799-- XXX We can perhaps use parseD monad instance for fusing with parseMany? Need
799-- XXX We can perhaps use parseD monad instance for fusing with parseMany? Need
800-- to measure the perf.
800-- to measure the perf.
801--
801--
802−readOneEvent :: Config -> Watch -> Parser IO Word8 Event
802+readOneEvent :: Config -> Watch -> Parser Word8 IO Event
803readOneEvent cfg wt@(Watch _ wdMap) = do
803readOneEvent cfg wt@(Watch _ wdMap) = do
804 let headerLen = sizeOf (undefined :: CInt) + 12
804 let headerLen = sizeOf (undefined :: CInt) + 12
805 arr <- PR.takeEQ headerLen (A.writeN headerLen)
805 arr <- PR.takeEQ headerLen (A.writeN headerLen)
test/Streamly/Test/Data/Parser.hs+2−2
@@ -259,7 +259,7 @@ takeGE =
259nLessThanEqual0 ::
259nLessThanEqual0 ::
260 ( Int
260 ( Int
261 -> FL.Fold (Either SomeException) Int [Int]
261 -> FL.Fold (Either SomeException) Int [Int]
262− -> P.Parser (Either SomeException) Int [Int]
262+ -> P.Parser Int (Either SomeException) [Int]
263 )
263 )
264 -> (Int -> [Int] -> [Int])
264 -> (Int -> [Int] -> [Int])
265 -> Property
265 -> Property
@@ -765,7 +765,7 @@ data Event = Event
765 , eventAbsPath :: A.Array Word8
765 , eventAbsPath :: A.Array Word8
766 } deriving (Show, Ord, Eq)
766 } deriving (Show, Ord, Eq)
767
767
768−readOneEvent :: P.Parser IO Word8 Event
768+readOneEvent :: P.Parser Word8 IO Event
769readOneEvent = do
769readOneEvent = do
770 arr <- P.takeEQ 24 (A.writeN 24)
770 arr <- P.takeEQ 24 (A.writeN 24)
771 let arr1 = A.castUnsafe arr :: A.Array Word64
771 let arr1 = A.castUnsafe arr :: A.Array Word64
test/Streamly/Test/Data/Parser/ParserD.hs+2−2
@@ -249,7 +249,7 @@ takeGE =
249nLessThanEqual0 ::
249nLessThanEqual0 ::
250 ( Int
250 ( Int
251 -> FL.Fold (Either SomeException) Int [Int]
251 -> FL.Fold (Either SomeException) Int [Int]
252− -> P.Parser (Either SomeException) Int [Int]
252+ -> P.Parser Int (Either SomeException) [Int]
253 )
253 )
254 -> (Int -> [Int] -> [Int])
254 -> (Int -> [Int] -> [Int])
255 -> Property
255 -> Property
@@ -702,7 +702,7 @@ data Event = Event
702 , eventAbsPath :: A.Array Word8
702 , eventAbsPath :: A.Array Word8
703 } deriving (Show, Ord, Eq)
703 } deriving (Show, Ord, Eq)
704
704
705−readOneEvent :: P.Parser IO Word8 Event
705+readOneEvent :: P.Parser Word8 IO Event
706readOneEvent = do
706readOneEvent = do
707 arr <- P.takeEQ 24 (A.writeN 24)
707 arr <- P.takeEQ 24 (A.writeN 24)
708 let arr1 = A.castUnsafe arr :: A.Array Word64
708 let arr1 = A.castUnsafe arr :: A.Array Word64