on master help sign in
Change "Parser m a b" to "Parser a m b"
commit239e3311ebf96907522484a2eb2c9ada21ecb379 authorAdithya Kumar <adithya@composewell.com> dateWed 2 Nov 2022, 20:46 (4 years ago) parentb851422
27 files changed+269−269
benchmark/Streamly/Benchmark/Data/Array/Stream/Unboxed.hs+1−1 benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1 benchmark/Streamly/Benchmark/Data/Parser/ParserK.hs+2−2 core/src/Streamly/Internal/Data/Array/Unboxed/Fold.hs+3−3 core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Stream.hs+1−1 core/src/Streamly/Internal/Data/Array/Unboxed/Stream.hs+6−6 core/src/Streamly/Internal/Data/Binary/Decode.hs+18−18 core/src/Streamly/Internal/Data/Fold/Type.hs+1−1 core/src/Streamly/Internal/Data/Parser.hs+83−83 core/src/Streamly/Internal/Data/Parser/ParserD.hs+54−54 core/src/Streamly/Internal/Data/Parser/ParserD/Tee.hs+5−5 core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+29−29 core/src/Streamly/Internal/Data/Parser/ParserK/Type.hs+15−15 core/src/Streamly/Internal/Data/Producer/Source.hs+4−4 core/src/Streamly/Internal/Data/Stream/Eliminate.hs+5−5 core/src/Streamly/Internal/Data/Stream/Reduce.hs+7−7 core/src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs+2−2 core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+3−3 core/src/Streamly/Internal/Data/Stream/StreamK.hs+1−1 core/src/Streamly/Internal/Unicode/Char/Parser.hs+11−11 core/src/Streamly/Internal/Unicode/Stream.hs+2−2 core/src/Streamly/Internal/Unicode/String.hs+2−2 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+7−7 src/Streamly/Internal/FileSystem/Event/Darwin.hs+1−1 src/Streamly/Internal/FileSystem/Event/Linux.hs+1−1 test/Streamly/Test/Data/Parser.hs+2−2 test/Streamly/Test/Data/Parser/ParserD.hs+2−2
benchmark/Streamly/Benchmark/Data/Array/Stream/Unboxed.hs+1−1
@@ -222,7 +222,7 @@ o_1_space_copy_toChunks_group_ungroup env =
222222-------------------------------------------------------------------------------
223223
224224{-# INLINE drainWhile #-}
225−drainWhile :: MonadCatch m => (a -> Bool) -> Parser.Parser m a ()
225+drainWhile :: MonadCatch m => (a -> Bool) -> Parser.Parser a m ()
226226drainWhile p = Parser.takeWhile p Fold.drain
227227
228228-------------------------------------------------------------------------------
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1
@@ -77,7 +77,7 @@ eqBy :: Int -> Stream IO Int -> IO ()
7777eqBy len = Stream.parseD (PR.eqBy (==) (D.enumerateFromToIntegral 1 len))
7878
7979{-# INLINE drainWhile #-}
80−drainWhile :: MonadThrow m => (a -> Bool) -> PR.Parser m a ()
80+drainWhile :: MonadThrow m => (a -> Bool) -> PR.Parser a m ()
8181drainWhile p = PR.takeWhile p Fold.drain
8282
8383{-# INLINE takeStartBy #-}
benchmark/Streamly/Benchmark/Data/Parser/ParserK.hs+2−2
@@ -65,11 +65,11 @@ benchIOSink value name f =
6565#endif
6666
6767{-# INLINE satisfy #-}
68−satisfy :: Monad m => (a -> Bool) -> PR.Parser m a a
68+satisfy :: Monad m => (a -> Bool) -> PR.Parser a m a
6969satisfy = PRD.toParserK . PRD.satisfy
7070
7171{-# INLINE takeWhile #-}
72−takeWhile :: Monad m => (a -> Bool) -> PR.Parser m a ()
72+takeWhile :: Monad m => (a -> Bool) -> PR.Parser a m ()
7373takeWhile p = PRD.toParserK $ PRD.takeWhile p FL.drain
7474
7575{-# INLINE takeWhileK #-}
core/src/Streamly/Internal/Data/Array/Unboxed/Fold.hs+3−3
@@ -88,7 +88,7 @@ import Prelude hiding (concatMap, take)
8888--
8989-- /Pre-release/
9090--
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)
9292
9393-------------------------------------------------------------------------------
9494-- Constructing array stream folds from element folds and parsers
@@ -145,7 +145,7 @@ fromParserD :: forall m a b. (MonadIO m) =>
145145#else
146146fromParserD :: forall m a b. (MonadIO m, Unbox a) =>
147147#endif
148− ParserD.Parser m a b -> ArrayFold m a b
148+ ParserD.Parser a m b -> ArrayFold m a b
149149fromParserD (ParserD.Parser step1 initial1 extract1) =
150150 ArrayFold (ParserD.Parser step initial1 extract1)
151151
@@ -191,7 +191,7 @@ fromParser :: forall m a b. (MonadThrow m, MonadIO m) =>
191191#else
192192fromParser :: forall m a b. (MonadThrow m, MonadIO m, Unbox a) =>
193193#endif
194− Parser.Parser m a b -> ArrayFold m a b
194+ Parser.Parser a m b -> ArrayFold m a b
195195fromParser = fromParserD . ParserD.fromParserK
196196
197197-- | 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
205205{-# INLINE_NORMAL compactLEParserD #-}
206206compactLEParserD ::
207207 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)
209209compactLEParserD n = ParserD.Parser step initial extract
210210
211211 where
core/src/Streamly/Internal/Data/Array/Unboxed/Stream.hs+6−6
@@ -554,7 +554,7 @@ newtype List a = List {getList :: [a]}
554554{-# INLINE_NORMAL parseBreakD #-}
555555parseBreakD ::
556556 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
557− => PRD.Parser m a b
557+ => PRD.Parser a m b
558558 -> D.Stream m (Array.Array a)
559559 -> m (b, D.Stream m (Array.Array a))
560560parseBreakD
@@ -635,7 +635,7 @@ parseBreakD
635635{-# INLINE_NORMAL parseBreakK #-}
636636parseBreakK ::
637637 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
638− => PRD.Parser m a b
638+ => PRD.Parser a m b
639639 -> K.Stream m (Array.Array a)
640640 -> m (b, K.Stream m (Array.Array a))
641641parseBreakK (PRD.Parser pstep initial extract) stream = do
@@ -770,7 +770,7 @@ parseBreakK (PRD.Parser pstep initial extract) stream = do
770770{-# INLINE_NORMAL parseBreak #-}
771771parseBreak ::
772772 (MonadIO m, MonadThrow m, Unbox a)
773− => PR.Parser m a b
773+ => PR.Parser a m b
774774 -> Stream m (A.Array a)
775775 -> m (b, Stream m (A.Array a))
776776{-
@@ -786,7 +786,7 @@ parseBreak p =
786786-- Elimination - Running Array Folds and parsers
787787-------------------------------------------------------------------------------
788788
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
790790-- regular "Streamly.Internal.Data.IsStream.parse" function. The regular parse
791791-- would consume the input arrays as single unit. This parser parses in the way
792792-- as described in the ArrayFold module. The input arrays are treated as @n@
@@ -796,7 +796,7 @@ parseBreak p =
796796{-# INLINE_NORMAL runArrayParserDBreak #-}
797797runArrayParserDBreak ::
798798 forall m a b. (MonadIO m, MonadThrow m, Unbox a)
799− => PRD.Parser m (Array a) b
799+ => PRD.Parser (Array a) m b
800800 -> D.Stream m (Array.Array a)
801801 -> m (b, D.Stream m (Array.Array a))
802802runArrayParserDBreak
@@ -925,7 +925,7 @@ runArrayParserDBreak
925925{-# INLINE parseArr #-}
926926parseArr ::
927927 (MonadIO m, MonadThrow m, Unbox a)
928− => ASF.Parser m a b
928+ => ASF.Parser a m b
929929 -> Stream m (A.Array a)
930930 -> m (b, Stream m (A.Array a))
931931parseArr 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
4848-- /Pre-release/
4949--
5050{-# INLINE unit #-}
51−unit :: Monad m => Parser m Word8 ()
51+unit :: Monad m => Parser Word8 m ()
5252unit = eqWord8 0 *> PR.fromPure ()
5353
5454{-# INLINE word8ToBool #-}
@@ -67,7 +67,7 @@ word8ToBool w = Left ("Invalid Bool encoding " ++ Prelude.show w)
6767-- /Pre-release/
6868--
6969{-# INLINE bool #-}
70−bool :: Monad m => Parser m Word8 Bool
70+bool :: Monad m => Parser Word8 m Bool
7171bool = PR.either word8ToBool
7272
7373{-# INLINE word8ToOrdering #-}
@@ -88,7 +88,7 @@ word8ToOrdering w = Left ("Invalid Ordering encoding " ++ Prelude.show w)
8888-- /Pre-release/
8989--
9090{-# INLINE ordering #-}
91−ordering :: Monad m => Parser m Word8 Ordering
91+ordering :: Monad m => Parser Word8 m Ordering
9292ordering = PR.either word8ToOrdering
9393
9494-- XXX should go in a Word8 parser module?
@@ -97,7 +97,7 @@ ordering = PR.either word8ToOrdering
9797-- /Pre-release/
9898--
9999{-# INLINE eqWord8 #-}
100−eqWord8 :: Monad m => Word8 -> Parser m Word8 Word8
100+eqWord8 :: Monad m => Word8 -> Parser Word8 m Word8
101101eqWord8 b = PR.satisfy (== b)
102102
103103-- | Accept any byte.
@@ -105,12 +105,12 @@ eqWord8 b = PR.satisfy (== b)
105105-- /Pre-release/
106106--
107107{-# INLINE word8 #-}
108−word8 :: Monad m => Parser m Word8 Word8
108+word8 :: Monad m => Parser Word8 m Word8
109109word8 = PR.satisfy (const True)
110110
111111-- | Big endian (MSB first) Word16
112112{-# INLINE word16beD #-}
113−word16beD :: Monad m => PRD.Parser m Word8 Word16
113+word16beD :: Monad m => PRD.Parser Word8 m Word16
114114word16beD = PRD.Parser step initial extract
115115
116116 where
@@ -132,12 +132,12 @@ word16beD = PRD.Parser step initial extract
132132-- /Pre-release/
133133--
134134{-# INLINE word16be #-}
135−word16be :: Monad m => Parser m Word8 Word16
135+word16be :: Monad m => Parser Word8 m Word16
136136word16be = PRD.toParserK word16beD
137137
138138-- | Little endian (LSB first) Word16
139139{-# INLINE word16leD #-}
140−word16leD :: Monad m => PRD.Parser m Word8 Word16
140+word16leD :: Monad m => PRD.Parser Word8 m Word16
141141word16leD = PRD.Parser step initial extract
142142
143143 where
@@ -157,12 +157,12 @@ word16leD = PRD.Parser step initial extract
157157-- /Pre-release/
158158--
159159{-# INLINE word16le #-}
160−word16le :: Monad m => Parser m Word8 Word16
160+word16le :: Monad m => Parser Word8 m Word16
161161word16le = PRD.toParserK word16leD
162162
163163-- | Big endian (MSB first) Word32
164164{-# INLINE word32beD #-}
165−word32beD :: Monad m => PRD.Parser m Word8 Word32
165+word32beD :: Monad m => PRD.Parser Word8 m Word32
166166word32beD = PRD.Parser step initial extract
167167
168168 where
@@ -184,12 +184,12 @@ word32beD = PRD.Parser step initial extract
184184-- /Pre-release/
185185--
186186{-# INLINE word32be #-}
187−word32be :: Monad m => Parser m Word8 Word32
187+word32be :: Monad m => Parser Word8 m Word32
188188word32be = PRD.toParserK word32beD
189189
190190-- | Little endian (LSB first) Word32
191191{-# INLINE word32leD #-}
192−word32leD :: Monad m => PRD.Parser m Word8 Word32
192+word32leD :: Monad m => PRD.Parser Word8 m Word32
193193word32leD = PRD.Parser step initial extract
194194
195195 where
@@ -210,12 +210,12 @@ word32leD = PRD.Parser step initial extract
210210-- /Pre-release/
211211--
212212{-# INLINE word32le #-}
213−word32le :: Monad m => Parser m Word8 Word32
213+word32le :: Monad m => Parser Word8 m Word32
214214word32le = PRD.toParserK word32leD
215215
216216-- | Big endian (MSB first) Word64
217217{-# INLINE word64beD #-}
218−word64beD :: Monad m => PRD.Parser m Word8 Word64
218+word64beD :: Monad m => PRD.Parser Word8 m Word64
219219word64beD = PRD.Parser step initial extract
220220
221221 where
@@ -237,12 +237,12 @@ word64beD = PRD.Parser step initial extract
237237-- /Pre-release/
238238--
239239{-# INLINE word64be #-}
240−word64be :: Monad m => Parser m Word8 Word64
240+word64be :: Monad m => Parser Word8 m Word64
241241word64be = PRD.toParserK word64beD
242242
243243-- | Little endian (LSB first) Word64
244244{-# INLINE word64leD #-}
245−word64leD :: Monad m => PRD.Parser m Word8 Word64
245+word64leD :: Monad m => PRD.Parser Word8 m Word64
246246word64leD = PRD.Parser step initial extract
247247
248248 where
@@ -263,7 +263,7 @@ word64leD = PRD.Parser step initial extract
263263-- /Pre-release/
264264--
265265{-# INLINE word64le #-}
266−word64le :: Monad m => Parser m Word8 Word64
266+word64le :: Monad m => Parser Word8 m Word64
267267word64le = PRD.toParserK word64leD
268268
269269-------------------------------------------------------------------------------
@@ -275,6 +275,6 @@ word64le = PRD.toParserK word64leD
275275-- /Pre-release/
276276--
277277{-# INLINE word64host #-}
278−word64host :: MonadIO m => Parser m Word8 Word64
278+word64host :: MonadIO m => Parser Word8 m Word64
279279word64host =
280280 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 @@
239239-- | Continue Int s -- no result and how much to backtrack
240240-- | Error String -- error
241241--
242−-- data Parser m a b =
242+-- data Parser a m b =
243243-- forall s. Fold
244244-- (s -> a -> m (Step s b)) -- step
245245-- (m (Step s b)) -- initial
core/src/Streamly/Internal/Data/Parser.hs+83−83
@@ -290,7 +290,7 @@ import Prelude hiding
290290-- /Pre-release/
291291--
292292{-# 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
294294toFold p = D.toFold $ D.fromParserK p
295295
296296-------------------------------------------------------------------------------
@@ -300,7 +300,7 @@ toFold p = D.toFold $ D.fromParserK p
300300-- | Make a 'Parser' from a 'Fold'.
301301--
302302{-# 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
304304fromFold = D.toParserK . D.fromFold
305305
306306-- | Convert a Maybe returning fold to an error returning parser. The first
@@ -310,7 +310,7 @@ fromFold = D.toParserK . D.fromFold
310310-- /Pre-release/
311311--
312312{-# 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
314314fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
315315
316316-------------------------------------------------------------------------------
@@ -322,7 +322,7 @@ fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
322322-- | A parser that always yields a pure value without consuming any input.
323323--
324324{-# INLINE [3] fromPure #-}
325−fromPure :: Monad m => b -> Parser m a b
325+fromPure :: Monad m => b -> Parser a m b
326326fromPure = D.toParserK . D.fromPure
327327{-# RULES "fromPure fallback to CPS" [2]
328328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
@@ -333,7 +333,7 @@ fromPure = D.toParserK . D.fromPure
333333-- consuming any input.
334334--
335335{-# INLINE fromEffect #-}
336−fromEffect :: Monad m => m b -> Parser m a b
336+fromEffect :: Monad m => m b -> Parser a m b
337337fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
338338
339339-- This is the dual of "nil".
@@ -342,7 +342,7 @@ fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
342342-- any input.
343343--
344344{-# INLINE [3] die #-}
345−die :: Monad m => String -> Parser m a b
345+die :: Monad m => String -> Parser a m b
346346die = D.toParserK . D.die
347347{-# RULES "die fallback to CPS" [2]
348348 forall a. D.toParserK (D.die a) = K.die a #-}
@@ -355,7 +355,7 @@ die = D.toParserK . D.die
355355-- /Pre-release/
356356--
357357{-# INLINE dieM #-}
358−dieM :: Monad m => m String -> Parser m a b
358+dieM :: Monad m => m String -> Parser a m b
359359dieM = D.toParserK . D.dieM
360360
361361-------------------------------------------------------------------------------
@@ -370,20 +370,20 @@ dieM = D.toParserK . D.dieM
370370-- > lmap = Parser.lmapM return
371371--
372372{-# 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
374374lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
375375
376376-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
377377--
378378{-# 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
380380lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
381381
382382-- | @rmapM f parser@ maps the monadic function @f@ on the output of the parser.
383383--
384384-- >>> rmap = fmap
385385{-# 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
387387rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
388388
389389-- | Include only those elements that pass a predicate.
@@ -392,7 +392,7 @@ rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
392392-- 40
393393--
394394{-# 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
396396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
397397
398398-------------------------------------------------------------------------------
@@ -410,7 +410,7 @@ filter f p = D.toParserK $ D.filter f $ D.fromParserK p
410410-- @
411411--
412412{-# INLINE peek #-}
413−peek :: Monad m => Parser m a a
413+peek :: Monad m => Parser a m a
414414peek = D.toParserK D.peek
415415
416416-- | Succeeds if we are at the end of input, fails otherwise.
@@ -419,7 +419,7 @@ peek = D.toParserK D.peek
419419-- (1,())
420420--
421421{-# INLINE eof #-}
422−eof :: Monad m => Parser m a ()
422+eof :: Monad m => Parser a m ()
423423eof = D.toParserK D.eof
424424
425425-- | Returns the next element if it passes the predicate, fails otherwise.
@@ -431,7 +431,7 @@ eof = D.toParserK D.eof
431431-- >>> satisfy f = Parser.maybe (toMaybe f)
432432--
433433{-# INLINE satisfy #-}
434−satisfy :: Monad m => (a -> Bool) -> Parser m a a
434+satisfy :: Monad m => (a -> Bool) -> Parser a m a
435435satisfy = D.toParserK . D.satisfy
436436
437437-- | Consume one element from the head of the stream. Fails if it encounters
@@ -440,7 +440,7 @@ satisfy = D.toParserK . D.satisfy
440440-- >>> one = Parser.satisfy $ const True
441441--
442442{-# INLINE one #-}
443−one :: Monad m => Parser m a a
443+one :: Monad m => Parser a m a
444444one = satisfy $ const True
445445
446446-- Alternate names: "only", "onlyThis".
@@ -450,7 +450,7 @@ one = satisfy $ const True
450450-- >>> oneEq x = Parser.satisfy (== x)
451451--
452452{-# INLINE oneEq #-}
453−oneEq :: (Monad m, Eq a) => a -> Parser m a a
453+oneEq :: (Monad m, Eq a) => a -> Parser a m a
454454oneEq x = satisfy (== x)
455455
456456-- Alternate names: "exclude", "notThis".
@@ -460,7 +460,7 @@ oneEq x = satisfy (== x)
460460-- >>> oneNotEq x = Parser.satisfy (/= x)
461461--
462462{-# INLINE oneNotEq #-}
463−oneNotEq :: (Monad m, Eq a) => a -> Parser m a a
463+oneNotEq :: (Monad m, Eq a) => a -> Parser a m a
464464oneNotEq x = satisfy (/= x)
465465
466466-- | Match any one of the elements in the supplied list.
@@ -484,7 +484,7 @@ oneNotEq x = satisfy (/= x)
484484-- search.
485485--
486486{-# 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
488488oneOf xs = satisfy (`Foldable.elem` xs)
489489
490490-- | See performance notes in 'oneOf'.
@@ -492,7 +492,7 @@ oneOf xs = satisfy (`Foldable.elem` xs)
492492-- >>> noneOf xs = Parser.satisfy (`Foldable.notElem` xs)
493493--
494494{-# 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
496496noneOf xs = satisfy (`Foldable.notElem` xs)
497497
498498-- | Return the next element of the input. Returns 'Nothing'
@@ -502,7 +502,7 @@ noneOf xs = satisfy (`Foldable.notElem` xs)
502502--
503503{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
504504{-# INLINE next #-}
505−next :: Monad m => Parser m a (Maybe a)
505+next :: Monad m => Parser a m (Maybe a)
506506next = D.toParserK D.next
507507
508508-- | Map a 'Maybe' returning function on the next element in the stream. The
@@ -517,7 +517,7 @@ next = D.toParserK D.next
517517-- /Pre-release/
518518--
519519{-# INLINE maybe #-}
520−maybe :: Monad m => (a -> Maybe b) -> Parser m a b
520+maybe :: Monad m => (a -> Maybe b) -> Parser a m b
521521maybe = D.toParserK . D.maybe
522522
523523-- | Map an 'Either' returning function on the next element in the stream. If
@@ -527,7 +527,7 @@ maybe = D.toParserK . D.maybe
527527-- /Pre-release/
528528--
529529{-# 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
531531either = D.toParserK . D.either
532532
533533-------------------------------------------------------------------------------
@@ -576,7 +576,7 @@ either = D.toParserK . D.either
576576--
577577{-# INLINE takeBetween #-}
578578takeBetween :: Monad m =>
579− Int -> Int -> Fold m a b -> Parser m a b
579+ Int -> Int -> Fold m a b -> Parser a m b
580580takeBetween m n = D.toParserK . D.takeBetween m n
581581
582582-- | Stops after taking exactly @n@ input elements.
@@ -589,7 +589,7 @@ takeBetween m n = D.toParserK . D.takeBetween m n
589589-- *** Exception: ParseError "takeEQ: Expecting exactly 4 elements, input terminated on 3"
590590--
591591{-# 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
593593takeEQ n = D.toParserK . D.takeEQ n
594594
595595-- | Take at least @n@ input elements, but can collect more.
@@ -607,7 +607,7 @@ takeEQ n = D.toParserK . D.takeEQ n
607607-- /Pre-release/
608608--
609609{-# 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
611611takeGE n = D.toParserK . D.takeGE n
612612
613613-------------------------------------------------------------------------------
@@ -634,7 +634,7 @@ takeGE n = D.toParserK . D.takeGE n
634634-- /Pre-release/
635635--
636636{-# 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
638638takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
639639
640640-- | 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)
655655-- @
656656--
657657{-# 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
659659takeWhile cond = D.toParserK . D.takeWhile cond
660660-- takeWhile cond f = takeWhileP cond (fromFold f)
661661
@@ -664,7 +664,7 @@ takeWhile cond = D.toParserK . D.takeWhile cond
664664-- >>> takeWhile1 cond p = Parser.takeWhileP cond (Parser.takeBetween 1 maxBound p)
665665--
666666{-# 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
668668takeWhile1 cond = D.toParserK . D.takeWhile1 cond
669669-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
670670
@@ -676,7 +676,7 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
676676-- >>> dropWhile p = Parser.takeWhile p Fold.drain
677677--
678678{-# INLINE dropWhile #-}
679−dropWhile :: Monad m => (a -> Bool) -> Parser m a ()
679+dropWhile :: Monad m => (a -> Bool) -> Parser a m ()
680680dropWhile p = takeWhile p FL.drain
681681
682682-------------------------------------------------------------------------------
@@ -690,7 +690,7 @@ takeFramedByGeneric :: Monad m =>
690690 -> Maybe (a -> Bool)
691691 -> Maybe (a -> Bool)
692692 -> Fold m a b
693− -> Parser m a b
693+ -> Parser a m b
694694takeFramedByGeneric esc begin end f =
695695 D.toParserK $ D.takeFramedByGeneric esc begin end f
696696
@@ -712,7 +712,7 @@ takeFramedByGeneric esc begin end f =
712712-- /Pre-release/
713713--
714714{-# 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
716716takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
717717-- takeEndBy = takeEndByEsc (const False)
718718
@@ -723,7 +723,7 @@ takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
723723-- /Pre-release/
724724--
725725{-# 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
727727takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
728728{-
729729takeEndBy_ isEnd p =
@@ -736,7 +736,7 @@ takeEndBy_ isEnd p =
736736-- /Unimplemented/
737737{-# INLINE takeEitherSepBy #-}
738738takeEitherSepBy :: -- 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
740740takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
741741
742742-- | 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
764764-- /Pre-release/
765765--
766766{-# 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
768768takeStartBy cond = D.toParserK . D.takeStartBy cond
769769
770770-- | Like 'takeStartBy' but drops the separator.
@@ -772,7 +772,7 @@ takeStartBy cond = D.toParserK . D.takeStartBy cond
772772-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
773773--
774774{-# 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
776776takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
777777
778778-------------------------------------------------------------------------------
@@ -786,7 +786,7 @@ takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
786786-- /pre-release/
787787{-# INLINE takeEndByEsc #-}
788788takeEndByEsc :: 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
790790takeEndByEsc isEsc isEnd p =
791791 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
792792
@@ -813,7 +813,7 @@ takeEndByEsc isEsc isEnd p =
813813-- /Pre-release/
814814{-# INLINE takeFramedByEsc_ #-}
815815takeFramedByEsc_ :: 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
817817takeFramedByEsc_ isEsc isBegin isEnd f =
818818 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
819819-- takeEndByEsc_ isEsc isEnd p =
@@ -826,7 +826,7 @@ takeFramedByEsc_ isEsc isBegin isEnd f =
826826--
827827{-# INLINE takeFramedBy_ #-}
828828takeFramedBy_ :: 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
830830takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
831831-- takeFramedBy_ isBegin isEnd =
832832-- takeFramedByGeneric (Just (const False)) (Just isBegin) (Just isEnd)
@@ -855,7 +855,7 @@ takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
855855-- @
856856--
857857{-# 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
859859wordBy f = D.toParserK . D.wordBy f
860860
861861-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
@@ -884,7 +884,7 @@ wordFramedBy :: Monad m =>
884884 -> (a -> Bool) -- ^ right quote
885885 -> (a -> Bool) -- ^ word seperator
886886 -> Fold m a b
887− -> Parser m a b
887+ -> Parser a m b
888888wordFramedBy isEsc isBegin isEnd isSpc =
889889 D.toParserK . D.wordFramedBy isEsc isBegin isEnd isSpc
890890
@@ -917,7 +917,7 @@ wordQuotedBy :: (Monad m, Eq a) =>
917917 -> (a -> a) -- ^ get right quote from left quote
918918 -> (a -> Bool) -- ^ word seperator
919919 -> Fold m a b
920− -> Parser m a b
920+ -> Parser a m b
921921wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
922922 D.toParserK . D.wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc
923923
@@ -948,7 +948,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
948948-- [[3,5,4],[1,2],[0]]
949949--
950950{-# 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
952952groupBy eq = D.toParserK . D.groupBy eq
953953
954954-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
@@ -982,7 +982,7 @@ groupBy eq = D.toParserK . D.groupBy eq
982982-- /Pre-release/
983983--
984984{-# 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
986986groupByRolling eq = D.toParserK . D.groupByRolling eq
987987
988988-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
@@ -997,7 +997,7 @@ groupByRolling eq = D.toParserK . D.groupByRolling eq
997997-- /Pre-release/
998998{-# INLINE groupByRollingEither #-}
999999groupByRollingEither :: 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)
10011001groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
10021002
10031003-- 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
10101010-- See also: "Streamly.Data.Stream.eqBy"
10111011--
10121012{-# 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 ()
10141014eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
10151015
10161016-- | Match the given sequence of elements using the given comparison function.
@@ -1029,7 +1029,7 @@ eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
10291029-- *** Exception: ParseError "eqBy: mismtach occurred"
10301030--
10311031{-# 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]
10331033-- listEqBy cmp xs = D.toParserK (D.listEqBy cmp xs)
10341034listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
10351035
@@ -1040,7 +1040,7 @@ listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
10401040-- >>> listEq = Parser.listEqBy (==)
10411041--
10421042{-# INLINE listEq #-}
1043−listEq :: (Monad m, Eq a) => [a] -> Parser m a [a]
1043+listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
10441044listEq = listEqBy (==)
10451045
10461046-- | Match if the input stream is a subsequence of the argument stream i.e. all
@@ -1049,7 +1049,7 @@ listEq = listEqBy (==)
10491049-- subsequence of itself.
10501050{-# INLINE subsequenceBy #-}
10511051subsequenceBy :: -- Monad m =>
1052− (a -> a -> Bool) -> Stream m a -> Parser m a ()
1052+ (a -> a -> Bool) -> Stream m a -> Parser a m ()
10531053subsequenceBy = undefined
10541054
10551055{-
@@ -1096,17 +1096,17 @@ regexPCRE = undefined
10961096-- primitives. Some common idioms are described below,
10971097--
10981098-- @
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
11001100-- span pred f1 f2 = serialWith (,) ('takeWhile' pred f1) ('fromFold' f2)
11011101-- @
11021102--
11031103-- @
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
11051105-- spanBy eq f1 f2 = serialWith (,) ('groupBy' eq f1) ('fromFold' f2)
11061106-- @
11071107--
11081108-- @
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
11101110-- spanByRolling eq f1 f2 = serialWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
11111111-- @
11121112--
@@ -1114,7 +1114,7 @@ regexPCRE = undefined
11141114--
11151115{-# INLINE serialWith #-}
11161116serialWith :: 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
11181118serialWith f p1 p2 =
11191119 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
11201120
@@ -1139,7 +1139,7 @@ serialWith f p1 p2 =
11391139-- /Pre-release/
11401140--
11411141{-# 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
11431143split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
11441144
11451145{-
@@ -1151,7 +1151,7 @@ split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
11511151--
11521152{-# INLINE teeWith #-}
11531153teeWith :: 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
11551155teeWith f p1 p2 =
11561156 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
11571157
@@ -1162,7 +1162,7 @@ teeWith f p1 p2 =
11621162--
11631163{-# INLINE teeWithFst #-}
11641164teeWithFst :: 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
11661166teeWithFst f p1 p2 =
11671167 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
11681168
@@ -1173,7 +1173,7 @@ teeWithFst f p1 p2 =
11731173--
11741174{-# INLINE teeWithMin #-}
11751175teeWithMin :: 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
11771177teeWithMin f p1 p2 =
11781178 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
11791179-}
@@ -1196,7 +1196,7 @@ teeWithMin f p1 p2 =
11961196-- /Pre-release/
11971197--
11981198{-# 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
12001200alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
12011201
12021202{-
@@ -1208,7 +1208,7 @@ alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
12081208--
12091209{-# INLINE shortest #-}
12101210shortest :: 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
12121212shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
12131213
12141214-- | 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)
12191219--
12201220{-# INLINE longest #-}
12211221longest :: 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
12231223longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
12241224-}
12251225
12261226-- | Run a parser without consuming the input.
12271227--
12281228{-# 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
12301230lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
12311231
12321232-- | Takes at-most @n@ input elements.
@@ -1242,7 +1242,7 @@ lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
12421242--
12431243-- /Internal/
12441244{-# 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
12461246takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
12471247
12481248-------------------------------------------------------------------------------
@@ -1261,7 +1261,7 @@ takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
12611261{-# INLINE concatSequence #-}
12621262concatSequence ::
12631263 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
12651265concatSequence f p =
12661266 let sp = fmap D.fromParserK $ Stream.toStreamD p
12671267 in D.toParserK $ D.sequence sp f
@@ -1277,7 +1277,7 @@ concatSequence f p =
12771277--
12781278{-# INLINE concatMap #-}
12791279concatMap :: 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
12811281concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
12821282
12831283{-
@@ -1294,7 +1294,7 @@ concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
12941294--
12951295{-# INLINE choice #-}
12961296choice ::
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
12981298choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
12991299-}
13001300
@@ -1309,7 +1309,7 @@ choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
13091309--
13101310{-# INLINE manyP #-}
13111311manyP :: -- 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
13131313manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
13141314
13151315-- | 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
13231323-- Compare with 'Control.Applicative.many'.
13241324--
13251325{-# 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
13271327many p f = D.toParserK $ D.many (D.fromParserK p) f
13281328
13291329-- 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
13421342-- Compare with 'Control.Applicative.some'.
13431343--
13441344{-# 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
13461346some p f = D.toParserK $ D.some (D.fromParserK p) f
13471347-- some p f = manyP p (takeGE 1 f)
13481348-- some = countBetween 1 maxBound
@@ -1357,7 +1357,7 @@ some p f = D.toParserK $ D.some (D.fromParserK p) f
13571357--
13581358{-# INLINE countBetween #-}
13591359countBetween :: -- 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
13611361countBetween _m _n _p = undefined
13621362-- countBetween m n p f = manyP p (takeBetween m n f)
13631363
@@ -1372,7 +1372,7 @@ countBetween _m _n _p = undefined
13721372--
13731373{-# INLINE count #-}
13741374count :: -- 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
13761376count n = countBetween n n
13771377-- count n p f = manyP p (takeEQ n f)
13781378
@@ -1389,7 +1389,7 @@ count n = countBetween n n
13891389--
13901390{-# INLINE manyTillP #-}
13911391manyTillP :: -- 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
13931393manyTillP _p1 _p2 _f = undefined
13941394 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
13951395
@@ -1403,11 +1403,11 @@ manyTillP _p1 _p2 _f = undefined
14031403--
14041404{-# INLINE manyTill #-}
14051405manyTill :: Monad m
1406− => Parser m a b -- ^ Chunking parser. Parses chunks of input.
1407− -> Parser m a x -- ^ Test parser. Parsing stops when this parser succeeds
1406+ => Parser a m b -- ^ Chunking parser. Parses chunks of input.
1407+ -> Parser a m x -- ^ Test parser. Parsing stops when this parser succeeds
14081408 -- else backtract and run the chunking parser.
14091409 -> Fold m b c -- ^ Folds the output of the chunking parser.
1410− -> Parser m a c
1410+ -> Parser a m c
14111411manyTill collect test f =
14121412 D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
14131413
@@ -1423,7 +1423,7 @@ manyTill collect test f =
14231423--
14241424{-# INLINE manyThen #-}
14251425manyThen :: -- (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
14271427manyThen _parser _recover _f = undefined
14281428
14291429-------------------------------------------------------------------------------
@@ -1453,10 +1453,10 @@ manyThen _parser _recover _f = undefined
14531453--
14541454{-# INLINE deintercalate #-}
14551455deintercalate :: Monad m =>
1456− Parser m a x
1457− -> Parser m a y
1456+ Parser a m x
1457+ -> Parser a m y
14581458 -> Fold m (Either x y) z
1459− -> Parser m a z
1459+ -> Parser a m z
14601460deintercalate contentL contentR sink =
14611461 D.toParserK
14621462 $ D.deintercalate
@@ -1470,7 +1470,7 @@ deintercalate contentL contentR sink =
14701470--
14711471{-# INLINE sepBy1 #-}
14721472sepBy1 :: 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
14741474sepBy1 p sep sink = do
14751475 x <- p
14761476 f <- fromEffect $ FL.reduce sink
@@ -1486,7 +1486,7 @@ sepBy1 p sep sink = do
14861486--
14871487{-# INLINE sepBy #-}
14881488sepBy :: 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
14901490sepBy content sep sink =
14911491 D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
14921492-- sepBy sink = deintercalate (FL.lefts sink)
@@ -1503,7 +1503,7 @@ sepBy content sep sink =
15031503--
15041504{-# INLINE roundRobin #-}
15051505roundRobin :: -- (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
15071507roundRobin _ps _f = undefined
15081508
15091509-------------------------------------------------------------------------------
@@ -1518,7 +1518,7 @@ roundRobin _ps _f = undefined
15181518--
15191519{-# INLINE retryMaxTotal #-}
15201520retryMaxTotal :: -- (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
15221522retryMaxTotal _n _p _f = undefined
15231523
15241524-- | Like 'retryMaxTotal' but aborts after @n@ successive failures.
@@ -1527,7 +1527,7 @@ retryMaxTotal _n _p _f = undefined
15271527--
15281528{-# INLINE retryMaxSuccessive #-}
15291529retryMaxSuccessive :: -- (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
15311531retryMaxSuccessive _n _p _f = undefined
15321532
15331533-- | Keep trying a parser until it succeeds. When the parser fails the input
@@ -1538,5 +1538,5 @@ retryMaxSuccessive _n _p _f = undefined
15381538--
15391539{-# INLINE retry #-}
15401540retry :: -- (Monad m) =>
1541− Parser m a b -> Parser m a b
1541+ Parser a m b -> Parser a m b
15421542retry _p = undefined
core/src/Streamly/Internal/Data/Parser/ParserD.hs+54−54
@@ -239,7 +239,7 @@ import Streamly.Internal.Data.Parser.ParserD.Type
239239-- /Internal/
240240--
241241{-# 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
243243toFold (Parser pstep pinitial pextract) = Fold step initial extract
244244
245245 where
@@ -286,7 +286,7 @@ toFold (Parser pstep pinitial pextract) = Fold step initial extract
286286-- /Pre-release/
287287--
288288{-# 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
290290fromFold (Fold fstep finitial fextract) = Parser step initial extract
291291
292292 where
@@ -312,7 +312,7 @@ fromFold (Fold fstep finitial fextract) = Parser step initial extract
312312-- /Pre-release/
313313--
314314{-# 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
316316fromFoldMaybe errMsg (Fold fstep finitial fextract) =
317317 Parser step initial extract
318318
@@ -353,7 +353,7 @@ fromFoldMaybe errMsg (Fold fstep finitial fextract) =
353353-- /Pre-release/
354354--
355355{-# INLINE peek #-}
356−peek :: Monad m => Parser m a a
356+peek :: Monad m => Parser a m a
357357peek = Parser step initial extract
358358
359359 where
@@ -369,7 +369,7 @@ peek = Parser step initial extract
369369-- /Pre-release/
370370--
371371{-# INLINE eof #-}
372−eof :: Monad m => Parser m a ()
372+eof :: Monad m => Parser a m ()
373373eof = Parser step initial extract
374374
375375 where
@@ -385,7 +385,7 @@ eof = Parser step initial extract
385385-- /Pre-release/
386386--
387387{-# INLINE next #-}
388−next :: Monad m => Parser m a (Maybe a)
388+next :: Monad m => Parser a m (Maybe a)
389389next = Parser step initial extract
390390
391391 where
@@ -401,7 +401,7 @@ next = Parser step initial extract
401401-- /Pre-release/
402402--
403403{-# 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
405405either f = Parser step initial extract
406406
407407 where
@@ -423,7 +423,7 @@ either f = Parser step initial extract
423423-- /Pre-release/
424424--
425425{-# INLINE maybe #-}
426−maybe :: Monad m => (a -> Maybe b) -> Parser m a b
426+maybe :: Monad m => (a -> Maybe b) -> Parser a m b
427427-- maybe f = either (Maybe.maybe (Left "maybe: predicate failed") Right . f)
428428maybe parserF = Parser step initial extract
429429
@@ -446,7 +446,7 @@ maybe parserF = Parser step initial extract
446446-- /Pre-release/
447447--
448448{-# INLINE satisfy #-}
449−satisfy :: Monad m => (a -> Bool) -> Parser m a a
449+satisfy :: Monad m => (a -> Bool) -> Parser a m a
450450-- satisfy predicate = maybe (\a -> if predicate a then Just a else Nothing)
451451satisfy predicate = Parser step initial extract
452452
@@ -474,7 +474,7 @@ data Tuple'Fused a b = Tuple'Fused !a !b deriving Show
474474-- /Pre-release/
475475--
476476{-# 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
478478takeBetween low high (Fold fstep finitial fextract) =
479479
480480 Parser step initial (extract streamErr)
@@ -551,7 +551,7 @@ takeBetween low high (Fold fstep finitial fextract) =
551551-- /Pre-release/
552552--
553553{-# 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
555555takeEQ n (Fold fstep finitial fextract) = Parser step initial extract
556556
557557 where
@@ -607,7 +607,7 @@ takeEQ n (Fold fstep finitial fextract) = Parser step initial extract
607607-- /Pre-release/
608608--
609609{-# 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
611611takeGE n (Fold fstep finitial fextract) = Parser step initial extract
612612
613613 where
@@ -664,7 +664,7 @@ takeGE n (Fold fstep finitial fextract) = Parser step initial extract
664664-- /Pre-release/
665665--
666666{-# 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
668668takeWhileP predicate (Parser pstep pinitial pextract) =
669669 Parser step pinitial pextract
670670
@@ -687,7 +687,7 @@ takeWhileP predicate (Parser pstep pinitial pextract) =
687687-- /Pre-release/
688688--
689689{-# 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
691691takeWhile predicate (Fold fstep finitial fextract) =
692692 Parser step initial extract
693693
@@ -716,7 +716,7 @@ takeWhile predicate (Fold fstep finitial fextract) =
716716-- /Pre-release/
717717--
718718{-# 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
720720takeWhile1 predicate (Fold fstep finitial fextract) =
721721 Parser step initial extract
722722
@@ -766,7 +766,7 @@ takeFramedByGeneric :: Monad m =>
766766 -> Maybe (a -> Bool)
767767 -> Maybe (a -> Bool)
768768 -> Fold m a b
769− -> Parser m a b
769+ -> Parser a m b
770770takeFramedByGeneric esc begin end (Fold fstep finitial fextract) =
771771
772772 Parser step initial extract
@@ -862,7 +862,7 @@ takeFramedByGeneric esc begin end (Fold fstep finitial fextract) =
862862-- /Pre-release/
863863--
864864{-# 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
866866takeEndBy cond (Parser pstep pinitial pextract) =
867867
868868 Parser step initial pextract
@@ -883,7 +883,7 @@ takeEndBy cond (Parser pstep pinitial pextract) =
883883--
884884{-# INLINE takeEndByEsc #-}
885885takeEndByEsc :: 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
887887takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
888888
889889 Parser step initial extract
@@ -914,7 +914,7 @@ takeEndByEsc isEsc isSep (Parser pstep pinitial pextract) =
914914-- /Pre-release/
915915--
916916{-# 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
918918takeEndBy_ cond (Parser pstep pinitial pextract) =
919919
920920 Parser step pinitial pextract
@@ -932,7 +932,7 @@ takeEndBy_ cond (Parser pstep pinitial pextract) =
932932--
933933
934934{-# 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
936936takeStartBy cond (Fold fstep finitial fextract) =
937937
938938 Parser step initial extract
@@ -968,7 +968,7 @@ takeStartBy cond (Fold fstep finitial fextract) =
968968
969969{-# INLINE takeFramedByEsc_ #-}
970970takeFramedByEsc_ :: 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
972972takeFramedByEsc_ isEsc isBegin isEnd (Fold fstep finitial fextract) =
973973
974974 Parser step initial extract
@@ -1019,7 +1019,7 @@ data FramedState s = FrameInit !s | FrameGo !s Int
10191019
10201020{-# INLINE takeFramedBy_ #-}
10211021takeFramedBy_ :: 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
10231023takeFramedBy_ isBegin isEnd (Fold fstep finitial fextract) =
10241024
10251025 Parser step initial extract
@@ -1068,7 +1068,7 @@ data WordByState s b = WBLeft !s | WBWord !s | WBRight !b
10681068--
10691069--
10701070{-# 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
10721072wordBy predicate (Fold fstep finitial fextract) = Parser step initial extract
10731073
10741074 where
@@ -1123,7 +1123,7 @@ wordFramedBy :: Monad m =>
11231123 -> (a -> Bool) -- ^ right quote
11241124 -> (a -> Bool) -- ^ word seperator
11251125 -> Fold m a b
1126− -> Parser m a b
1126+ -> Parser a m b
11271127wordFramedBy isEsc isBegin isEnd isSep
11281128 (Fold fstep finitial fextract) =
11291129 Parser step initial extract
@@ -1215,7 +1215,7 @@ wordQuotedBy :: (Monad m, Eq a) =>
12151215 -> (a -> a) -- ^ get right quote from the left quote
12161216 -> (a -> Bool) -- ^ word seperator
12171217 -> Fold m a b
1218− -> Parser m a b
1218+ -> Parser a m b
12191219wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSep
12201220 (Fold fstep finitial fextract) =
12211221 Parser step initial extract
@@ -1316,7 +1316,7 @@ data GroupByState a s
13161316-- | See 'Streamly.Internal.Data.Parser.groupBy'.
13171317--
13181318{-# 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
13201320groupBy eq (Fold fstep finitial fextract) = Parser step initial extract
13211321
13221322 where
@@ -1348,7 +1348,7 @@ groupBy eq (Fold fstep finitial fextract) = Parser step initial extract
13481348-- | See 'Streamly.Internal.Data.Parser.groupByRolling'.
13491349--
13501350{-# 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
13521352groupByRolling eq (Fold fstep finitial fextract) = Parser step initial extract
13531353
13541354 where
@@ -1386,7 +1386,7 @@ data GroupByStatePair a s1 s2
13861386
13871387{-# INLINE groupByRollingEither #-}
13881388groupByRollingEither :: 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)
13901390groupByRollingEither
13911391 eq
13921392 (Fold fstep1 finitial1 fextract1)
@@ -1474,7 +1474,7 @@ groupByRollingEither
14741474-- /Pre-release/
14751475--
14761476{-# 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]
14781478listEqBy cmp str = Parser step initial extract
14791479
14801480 where
@@ -1504,7 +1504,7 @@ listEqBy cmp str = Parser step initial extract
15041504
15051505-- | Like 'listEqBy' but uses a stream instead of a list
15061506{-# 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 ()
15081508eqBy cmp (D.Stream sstep state) = Parser step initial extract
15091509
15101510 where
@@ -1555,12 +1555,12 @@ eqBy cmp (D.Stream sstep state) = Parser step initial extract
15551555--
15561556{-# INLINE postscan #-}
15571557postscan :: -- 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
15591559postscan = undefined
15601560
15611561{-# INLINE zipWithM #-}
15621562zipWithM :: 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
15641564zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
15651565 Parser step initial extract
15661566
@@ -1615,14 +1615,14 @@ zipWithM zf (D.Stream sstep state) (Fold fstep finitial fextract) =
16151615-- /Pre-release/
16161616--
16171617{-# 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
16191619zip = zipWithM (curry return)
16201620
16211621-- | Pair each element of a fold input with its index, starting from index 0.
16221622--
16231623-- /Pre-release/
16241624{-# 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
16261626indexed = zip (D.enumerateFromIntegral 0 :: D.Stream m Int)
16271627
16281628-- | @makeIndexFilter indexer filter predicate@ generates a fold filtering
@@ -1641,9 +1641,9 @@ indexed = zip (D.enumerateFromIntegral 0 :: D.Stream m Int)
16411641-- /Pre-release/
16421642{-# INLINE makeIndexFilter #-}
16431643makeIndexFilter ::
1644− (Fold m (s, a) b -> Parser m a b)
1644+ (Fold m (s, a) b -> Parser a m b)
16451645 -> (((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)
16471647makeIndexFilter f comb g = f . comb g . FL.lmap snd
16481648
16491649-- | @sampleFromthen offset stride@ samples the element at @offset@ index and
@@ -1651,7 +1651,7 @@ makeIndexFilter f comb g = f . comb g . FL.lmap snd
16511651--
16521652-- /Pre-release/
16531653{-# 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
16551655sampleFromthen offset size =
16561656 makeIndexFilter indexed FL.filter (\(i, _) -> (i + offset) `mod` size == 0)
16571657
@@ -1679,7 +1679,7 @@ sampleFromthen offset size =
16791679--
16801680-- /Pre-release/
16811681{-# 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)
16831683span p f1 f2 = noErrorUnsafeSplitWith (,) (takeWhile p f1) (fromFold f2)
16841684
16851685-- | 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)
16911691{-# INLINE spanBy #-}
16921692spanBy ::
16931693 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)
16951695spanBy eq f1 f2 = noErrorUnsafeSplitWith (,) (groupBy eq f1) (fromFold f2)
16961696
16971697-- | 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)
17011701{-# INLINE spanByRolling #-}
17021702spanByRolling ::
17031703 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)
17051705spanByRolling eq f1 f2 =
17061706 noErrorUnsafeSplitWith (,) (groupByRolling eq f1) (fromFold f2)
17071707
@@ -1713,7 +1713,7 @@ spanByRolling eq f1 f2 =
17131713--
17141714-- /Internal/
17151715{-# 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
17171717takeP lim (Parser pstep pinitial pextract) = Parser step initial extract
17181718
17191719 where
@@ -1788,7 +1788,7 @@ takeP lim (Parser pstep pinitial pextract) = Parser step initial extract
17881788-- /Pre-release/
17891789--
17901790{-# 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
17921792lookAhead (Parser step1 initial1 _) = Parser step initial extract
17931793
17941794 where
@@ -1833,10 +1833,10 @@ data DeintercalateState fs sp ss =
18331833--
18341834{-# INLINE deintercalate #-}
18351835deintercalate :: Monad m =>
1836− Parser m a x
1837− -> Parser m a y
1836+ Parser a m x
1837+ -> Parser a m y
18381838 -> Fold m (Either x y) z
1839− -> Parser m a z
1839+ -> Parser a m z
18401840deintercalate
18411841 (Parser stepL initialL extractL)
18421842 (Parser stepR initialR extractR)
@@ -1930,7 +1930,7 @@ data SepByState fs sp ss =
19301930-- terms of deintercalate.
19311931{-# INLINE sepBy #-}
19321932sepBy :: 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
19341934sepBy
19351935 (Parser pstep pinitial pextract)
19361936 (Parser sstep sinitial _)
@@ -2007,7 +2007,7 @@ sepBy
20072007-- | See 'Streamly.Internal.Data.Parser.sequence'.
20082008{-# INLINE sequence #-}
20092009sequence :: 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
20112011sequence (D.Stream sstep sstate) (Fold fstep finitial fextract) =
20122012 Parser step initial extract
20132013
@@ -2094,7 +2094,7 @@ sequence (D.Stream sstep sstate) (Fold fstep finitial fextract) =
20942094-- /Broken/
20952095--
20962096{-# 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
20982098choice = foldl1 shortest
20992099-}
21002100
@@ -2104,7 +2104,7 @@ choice = foldl1 shortest
21042104
21052105{-# INLINE manyP #-}
21062106manyP :: -- 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
21082108manyP _p _f = undefined
21092109
21102110-- | See 'Streamly.Internal.Data.Parser.many'.
@@ -2112,7 +2112,7 @@ manyP _p _f = undefined
21122112-- /Pre-release/
21132113--
21142114{-# 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
21162116many = splitMany
21172117-- many = countBetween 0 maxBound
21182118
@@ -2121,7 +2121,7 @@ many = splitMany
21212121-- /Pre-release/
21222122--
21232123{-# 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
21252125some = splitSome
21262126-- some p f = manyP p (takeGE 1 f)
21272127-- some = countBetween 1 maxBound
@@ -2132,7 +2132,7 @@ some = splitSome
21322132--
21332133{-# INLINE countBetween #-}
21342134countBetween :: -- 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
21362136countBetween _m _n _p = undefined
21372137-- countBetween m n p f = manyP p (takeBetween m n f)
21382138
@@ -2142,7 +2142,7 @@ countBetween _m _n _p = undefined
21422142--
21432143{-# INLINE count #-}
21442144count :: -- 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
21462146count n = countBetween n n
21472147-- count n p f = manyP p (takeEQ n f)
21482148
@@ -2156,7 +2156,7 @@ data ManyTillState fs sr sl
21562156--
21572157{-# INLINE manyTill #-}
21582158manyTill :: 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
21602160manyTill (Parser stepL initialL extractL)
21612161 (Parser stepR initialR _)
21622162 (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
104104--
105105{-# INLINE teeWith #-}
106106teeWith :: 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
108108teeWith zf (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
109109 Parser step initial extract
110110
@@ -246,7 +246,7 @@ teeWith zf (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
246246--
247247{-# INLINE teeWithFst #-}
248248teeWithFst :: 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
250250teeWithFst zf (Parser stepL initialL extractL)
251251 (Parser stepR initialR extractR) =
252252 Parser step initial extract
@@ -370,7 +370,7 @@ teeWithFst zf (Parser stepL initialL extractL)
370370{-# INLINE teeWithMin #-}
371371teeWithMin ::
372372 -- 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
374374teeWithMin = undefined
375375
376376-------------------------------------------------------------------------------
@@ -382,7 +382,7 @@ teeWithMin = undefined
382382-- /Broken/
383383--
384384{-# 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
386386shortest (Parser stepL initialL extractL) (Parser stepR initialR _) =
387387 Parser step initial extract
388388
@@ -471,7 +471,7 @@ shortest (Parser stepL initialL extractL) (Parser stepR initialR _) =
471471-- /Broken/
472472--
473473{-# 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
475475longest (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
476476 Parser step initial extract
477477
core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+29−29
@@ -417,7 +417,7 @@ mapMStep f res =
417417--
418418-- /Pre-release/
419419--
420−data Parser m a b =
420+data Parser a m b =
421421 forall s. Parser
422422 (s -> a -> m (Step s b))
423423 -- Initial cannot return "Partial/Done n" or "Continue". Continue 0 is
@@ -439,7 +439,7 @@ newtype ParseError = ParseError String
439439instance Exception ParseError where
440440 displayException (ParseError err) = err
441441
442−instance Functor m => Functor (Parser m a) where
442+instance Functor m => Functor (Parser a m) where
443443 {-# INLINE fmap #-}
444444 fmap f (Parser step1 initial1 extract) =
445445 Parser step initial (fmap3 f extract)
@@ -565,7 +565,7 @@ parseDToK pstep initial extract leftover (level, count) cont = do
565565-- /Pre-release/
566566--
567567{-# 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
569569toParserK (Parser step initial extract) =
570570 K.MkParser $ parseDToK step initial extract
571571
@@ -589,7 +589,7 @@ parserDone st _ =
589589-- /Pre-release/
590590--
591591{-# 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
593593fromParserK parser = Parser step initial extract
594594
595595 where
@@ -633,7 +633,7 @@ fromParserK parser = Parser step initial extract
633633--
634634-- /Pre-release/
635635{-# 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
637637rmapM f (Parser step initial extract) =
638638 Parser step1 initial1 (extract >=> mapMStep f)
639639
@@ -653,7 +653,7 @@ rmapM f (Parser step initial extract) =
653653-- /Pre-release/
654654--
655655{-# INLINE_NORMAL fromPure #-}
656−fromPure :: Monad m => b -> Parser m a b
656+fromPure :: Monad m => b -> Parser a m b
657657fromPure b = Parser undefined (pure $ IDone b) undefined
658658
659659-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
@@ -661,7 +661,7 @@ fromPure b = Parser undefined (pure $ IDone b) undefined
661661-- /Pre-release/
662662--
663663{-# INLINE fromEffect #-}
664−fromEffect :: Monad m => m b -> Parser m a b
664+fromEffect :: Monad m => m b -> Parser a m b
665665fromEffect b = Parser undefined (IDone <$> b) undefined
666666
667667-------------------------------------------------------------------------------
@@ -684,7 +684,7 @@ data SeqParseState sl f sr = SeqParseL sl | SeqParseR f sr
684684--
685685{-# INLINE serialWith #-}
686686serialWith :: 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
688688serialWith func (Parser stepL initialL extractL)
689689 (Parser stepR initialR extractR) =
690690 Parser step initial extract
@@ -767,7 +767,7 @@ serialWith func (Parser stepL initialL extractL)
767767-- | Works correctly only if both the parsers are guaranteed to never fail.
768768{-# INLINE noErrorUnsafeSplitWith #-}
769769noErrorUnsafeSplitWith :: 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
771771noErrorUnsafeSplitWith func (Parser stepL initialL extractL)
772772 (Parser stepR initialR extractR) =
773773 Parser step initial extract
@@ -833,7 +833,7 @@ data SeqAState sl sr = SeqAL sl | SeqAR sr
833833-- /Pre-release/
834834--
835835{-# 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
837837split_ (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
838838 Parser step initial extract
839839
@@ -887,7 +887,7 @@ split_ (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
887887
888888-- For backtracking folds
889889{-# 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
891891noErrorUnsafeSplit_
892892 (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
893893 Parser step initial extract
@@ -941,7 +941,7 @@ noErrorUnsafeSplit_
941941 Continue n s -> return $ Continue n (SeqAL s)
942942
943943-- | 'Applicative' form of 'serialWith'.
944−instance Monad m => Applicative (Parser m a) where
944+instance Monad m => Applicative (Parser a m) where
945945 {-# INLINE pure #-}
946946 pure = fromPure
947947
@@ -973,7 +973,7 @@ data AltParseState sl sr = AltParseL Int sl | AltParseR sr
973973-- /Pre-release/
974974--
975975{-# 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
977977alt (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
978978 Parser step initial extract
979979
@@ -1043,7 +1043,7 @@ alt (Parser stepL initialL extractL) (Parser stepR initialR extractR) =
10431043-- /Pre-release/
10441044--
10451045{-# 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
10471047splitMany (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
10481048 Parser step initial extract
10491049
@@ -1107,7 +1107,7 @@ splitMany (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
11071107-- /Internal/
11081108--
11091109{-# 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
11111111splitManyPost (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
11121112 Parser step initial extract
11131113
@@ -1169,7 +1169,7 @@ splitManyPost (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
11691169-- /Pre-release/
11701170--
11711171{-# 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
11731173splitSome (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
11741174 Parser step initial extract
11751175
@@ -1272,7 +1272,7 @@ splitSome (Parser step1 initial1 extract1) (Fold fstep finitial fextract) =
12721272-- /Pre-release/
12731273--
12741274{-# INLINE_NORMAL die #-}
1275−die :: Monad m => String -> Parser m a b
1275+die :: Monad m => String -> Parser a m b
12761276die err = Parser undefined (pure (IError err)) undefined
12771277
12781278-- | See 'Streamly.Internal.Data.Parser.dieM'.
@@ -1280,7 +1280,7 @@ die err = Parser undefined (pure (IError err)) undefined
12801280-- /Pre-release/
12811281--
12821282{-# INLINE dieM #-}
1283−dieM :: Monad m => m String -> Parser m a b
1283+dieM :: Monad m => m String -> Parser a m b
12841284dieM err = Parser undefined (IError <$> err) undefined
12851285
12861286-- Note: The default implementations of "some" and "many" loop infinitely
@@ -1299,7 +1299,7 @@ dieM err = Parser undefined (IError <$> err) undefined
12991299-- >>> Stream.parse (Parser.satisfy (> 0) <|> undefined) $ Stream.fromList [1..10]
13001300-- 1
13011301--
1302−instance Monad m => Alternative (Parser m a) where
1302+instance Monad m => Alternative (Parser a m) where
13031303 {-# INLINE empty #-}
13041304 empty = die "empty"
13051305
@@ -1323,7 +1323,7 @@ data ConcatParseState sl m a b =
13231323--
13241324{-# INLINE concatMap #-}
13251325concatMap :: 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
13271327concatMap func (Parser stepL initialL extractL) = Parser step initial extract
13281328
13291329 where
@@ -1390,7 +1390,7 @@ concatMap func (Parser stepL initialL extractL) = Parser step initial extract
13901390
13911391{-# INLINE noErrorUnsafeConcatMap #-}
13921392noErrorUnsafeConcatMap :: 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
13941394noErrorUnsafeConcatMap func (Parser stepL initialL extractL) =
13951395 Parser step initial extract
13961396
@@ -1462,7 +1462,7 @@ noErrorUnsafeConcatMap func (Parser stepL initialL extractL) =
14621462
14631463-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
14641464--
1465−instance Monad m => Monad (Parser m a) where
1465+instance Monad m => Monad (Parser a m) where
14661466 {-# INLINE return #-}
14671467 return = pure
14681468
@@ -1474,14 +1474,14 @@ instance Monad m => Monad (Parser m a) where
14741474
14751475-- | See documentation of 'Streamly.Internal.Data.Parser.ParserK.Type.Parser'.
14761476--
1477−instance Monad m => MonadPlus (Parser m a) where
1477+instance Monad m => MonadPlus (Parser a m) where
14781478 {-# INLINE mzero #-}
14791479 mzero = die "mzero"
14801480
14811481 {-# INLINE mplus #-}
14821482 mplus = alt
14831483
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
14851485 {-# INLINE ask #-}
14861486 ask = fromEffect ask
14871487
@@ -1491,14 +1491,14 @@ instance (Monad m, MonadReader r m) => MonadReader r (Parser m a) where
14911491 (local f init')
14921492 (local f . extract)
14931493
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
14951495 {-# INLINE get #-}
14961496 get = fromEffect get
14971497
14981498 {-# INLINE put #-}
14991499 put = fromEffect . put
15001500
1501−instance (Monad m, MonadIO m) => MonadIO (Parser m a) where
1501+instance (Monad m, MonadIO m) => MonadIO (Parser a m) where
15021502 {-# INLINE liftIO #-}
15031503 liftIO = fromEffect . liftIO
15041504
@@ -1507,7 +1507,7 @@ instance (Monad m, MonadIO m) => MonadIO (Parser m a) where
15071507------------------------------------------------------------------------------
15081508
15091509{-# 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
15111511lmap f (Parser step begin done) = Parser step1 begin done
15121512
15131513 where
@@ -1515,7 +1515,7 @@ lmap f (Parser step begin done) = Parser step1 begin done
15151515 step1 x a = step x (f a)
15161516
15171517{-# 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
15191519lmapM f (Parser step begin done) = Parser step1 begin done
15201520
15211521 where
@@ -1523,7 +1523,7 @@ lmapM f (Parser step begin done) = Parser step1 begin done
15231523 step1 x a = f a >>= step x
15241524
15251525{-# 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
15271527filter f (Parser step initial extract) = Parser step1 initial extract
15281528
15291529 where
core/src/Streamly/Internal/Data/Parser/ParserK/Type.hs+15−15
@@ -82,7 +82,7 @@ instance Functor Parse where
8282-- input without a result or return a result with no further input to be
8383-- consumed.
8484--
85−newtype Parser m a b = MkParser
85+newtype Parser a m b = MkParser
8686 { runParser :: forall r.
8787 -- leftover: the number of elements that were not used by the
8888 -- previous consumer and should be carried forward.
@@ -111,7 +111,7 @@ newtype Parser m a b = MkParser
111111-- XXX rewrite this using ParserD, expose rmapM from ParserD.
112112-- | Maps a function over the output of the parser.
113113--
114−instance Functor m => Functor (Parser m a) where
114+instance Functor m => Functor (Parser a m) where
115115 {-# INLINE fmap #-}
116116 fmap f parser = MkParser $ \n st k ->
117117 let k1 s res = k s (fmap f res)
@@ -128,7 +128,7 @@ instance Functor m => Functor (Parser m a) where
128128-- /Pre-release/
129129--
130130{-# INLINE fromPure #-}
131−fromPure :: b -> Parser m a b
131+fromPure :: b -> Parser a m b
132132fromPure b = MkParser $ \n st k -> k st (Success n b)
133133
134134-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
@@ -136,14 +136,14 @@ fromPure b = MkParser $ \n st k -> k st (Success n b)
136136-- /Pre-release/
137137--
138138{-# INLINE fromEffect #-}
139−fromEffect :: Monad m => m b -> Parser m a b
139+fromEffect :: Monad m => m b -> Parser a m b
140140fromEffect eff = MkParser $ \n st k -> eff >>= \b -> k st (Success n b)
141141
142142-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.serialWith'. Note that
143143-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.serialWith'
144144-- when fusion is important.
145145--
146−instance Monad m => Applicative (Parser m a) where
146+instance Monad m => Applicative (Parser a m) where
147147 {-# INLINE pure #-}
148148 pure = fromPure
149149
@@ -180,7 +180,7 @@ instance Monad m => Applicative (Parser m a) where
180180-- /Pre-release/
181181--
182182{-# INLINE die #-}
183−die :: String -> Parser m a b
183+die :: String -> Parser a m b
184184die err = MkParser (\_ st k -> k st (Failure err))
185185
186186-- | 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))
190190-- following parser:
191191--
192192-- @
193−-- backtracking :: MonadCatch m => PR.Parser m Char String
193+-- backtracking :: MonadCatch m => PR.Parser Char m String
194194-- backtracking =
195195-- sequence [PR.satisfy isDigit, PR.satisfy isAlpha]
196196-- '<|>'
@@ -206,7 +206,7 @@ die err = MkParser (\_ st k -> k st (Failure err))
206206-- @
207207-- data DigitOrAlpha = Digit Char | Alpha Char
208208--
209−-- lookbehind :: MonadCatch m => PR.Parser m Char String
209+-- lookbehind :: MonadCatch m => PR.Parser Char m String
210210-- lookbehind = do
211211-- x1 \<- Digit '<$>' PR.satisfy isDigit
212212-- '<|>' Alpha '<$>' PR.satisfy isAlpha
@@ -225,7 +225,7 @@ die err = MkParser (\_ st k -> k st (Failure err))
225225-- does not fuse, use 'Streamly.Internal.Data.Parser.concatMap' when you need
226226-- fusion.
227227--
228−instance Monad m => Monad (Parser m a) where
228+instance Monad m => Monad (Parser a m) where
229229 {-# INLINE return #-}
230230 return = pure
231231
@@ -244,12 +244,12 @@ instance Monad m => Monad (Parser m a) where
244244 {-# INLINE fail #-}
245245 fail = die
246246#endif
247−instance Monad m => Fail.MonadFail (Parser m a) where
247+instance Monad m => Fail.MonadFail (Parser a m) where
248248 {-# INLINE fail #-}
249249 fail = die
250250
251251instance (MonadThrow m, MonadReader r m, MonadCatch m) =>
252− MonadReader r (Parser m a) where
252+ MonadReader r (Parser a m) where
253253
254254 {-# INLINE ask #-}
255255 ask = fromEffect ask
@@ -257,14 +257,14 @@ instance (MonadThrow m, MonadReader r m, MonadCatch m) =>
257257 {-# INLINE local #-}
258258 local f p = MkParser $ \n st k -> local f $ runParser p n st k
259259
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
261261 {-# INLINE get #-}
262262 get = fromEffect get
263263
264264 {-# INLINE put #-}
265265 put = fromEffect . put
266266
267−instance (MonadThrow m, MonadIO m) => MonadIO (Parser m a) where
267+instance (MonadThrow m, MonadIO m) => MonadIO (Parser a m) where
268268 {-# INLINE liftIO #-}
269269 liftIO = fromEffect . liftIO
270270
@@ -285,7 +285,7 @@ instance (MonadThrow m, MonadIO m) => MonadIO (Parser m a) where
285285-- does not fuse, use 'Streamly.Internal.Data.Parser.alt' when you need
286286-- fusion.
287287--
288−instance Monad m => Alternative (Parser m a) where
288+instance Monad m => Alternative (Parser a m) where
289289 {-# INLINE empty #-}
290290 empty = die "empty"
291291
@@ -318,7 +318,7 @@ instance Monad m => Alternative (Parser m a) where
318318-- | 'mzero' is same as 'empty', it aborts the parser. 'mplus' is same as
319319-- '<|>', it selects the first succeeding parser.
320320--
321−instance Monad m => MonadPlus (Parser m a) where
321+instance Monad m => MonadPlus (Parser a m) where
322322 {-# INLINE mzero #-}
323323 mzero = die "mzero"
324324
core/src/Streamly/Internal/Data/Producer/Source.hs+4−4
@@ -113,7 +113,7 @@ newtype List a = List {getList :: [a]}
113113{-# INLINE_NORMAL parseD #-}
114114parseD
115115 :: MonadThrow m
116− => ParserD.Parser m a b
116+ => ParserD.Parser a m b
117117 -> Producer m (Source s a) a
118118 -> Source s a
119119 -> m (b, Source s a)
@@ -243,7 +243,7 @@ parseD
243243{-# INLINE [3] parse #-}
244244parse
245245 :: MonadThrow m
246− => ParserK.Parser m a b
246+ => ParserK.Parser a m b
247247 -> Producer m (Source s a) a
248248 -> Source s a
249249 -> m (b, Source s a)
@@ -255,7 +255,7 @@ parse = parseD . ParserD.fromParserK
255255
256256{-# INLINE parseManyD #-}
257257parseManyD :: MonadThrow m =>
258− ParserD.Parser m a b
258+ ParserD.Parser a m b
259259 -> Producer m (Source x a) a
260260 -> Producer m (Source x a) b
261261parseManyD parser reader = Producer step return return
@@ -276,7 +276,7 @@ parseManyD parser reader = Producer step return return
276276-- /Pre-release/
277277{-# INLINE parseMany #-}
278278parseMany :: MonadThrow m =>
279− ParserK.Parser m a b
279+ ParserK.Parser a m b
280280 -> Producer m (Source x a) a
281281 -> Producer m (Source x a) b
282282parseMany 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)
230230-- /Internal/
231231--
232232{-# 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
234234parseD p = D.parse p . toStreamD
235235
236236-- XXX Drive directly as parserK rather than converting to parserD first.
@@ -239,7 +239,7 @@ parseD p = D.parse p . toStreamD
239239--
240240-- /Internal/
241241{-# 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
243243parseK = parse
244244
245245-- | Parse a stream using the supplied 'Parser'.
@@ -255,12 +255,12 @@ parseK = parse
255255-- Note: @parse p@ is not the same as @head . parseMany p@ on an empty stream.
256256--
257257{-# 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
259259parse = parseD . PRD.fromParserK
260260
261261{-# INLINE_NORMAL parseBreakD #-}
262262parseBreakD :: 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)
264264parseBreakD parser strm = do
265265 (b, strmD) <- D.parseBreak parser (toStreamD strm)
266266 return $! (b, fromStreamD strmD)
@@ -270,7 +270,7 @@ parseBreakD parser strm = do
270270-- /Not fused/
271271--
272272{-# 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)
274274parseBreak p strm = fmap f $ K.parseBreak (PRD.fromParserK p) (toStreamK strm)
275275
276276 where
core/src/Streamly/Internal/Data/Stream/Reduce.hs+7−7
@@ -22,7 +22,7 @@ module Streamly.Internal.Data.Stream.Reduce
2222 --
2323 -- @
2424 -- 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
2626 -- @
2727
2828 -- ** Generic Folding
@@ -339,7 +339,7 @@ splitOnAny _subseq _f _m =
339339{-# INLINE parseMany #-}
340340parseMany
341341 :: MonadThrow m
342− => Parser m a b
342+ => Parser a m b
343343 -> Stream m a
344344 -> Stream m b
345345parseMany p m =
@@ -352,7 +352,7 @@ parseMany p m =
352352{-# INLINE parseManyD #-}
353353parseManyD
354354 :: MonadThrow m
355− => ParserD.Parser m a b
355+ => ParserD.Parser a m b
356356 -> Stream m a
357357 -> Stream m b
358358parseManyD p m =
@@ -366,7 +366,7 @@ parseManyD p m =
366366{-# INLINE parseSequence #-}
367367parseSequence
368368 :: -- Monad m =>
369− Stream m (Parser m a b)
369+ Stream m (Parser a m b)
370370 -> Stream m a
371371 -> Stream m b
372372parseSequence _f _m = undefined
@@ -384,8 +384,8 @@ parseSequence _f _m = undefined
384384{-# INLINE parseManyTill #-}
385385parseManyTill ::
386386 -- MonadThrow m =>
387− Parser m a b
388− -> Parser m a x
387+ Parser a m b
388+ -> Parser a m x
389389 -> t m a
390390 -> t m b
391391parseManyTill = undefined
@@ -407,7 +407,7 @@ parseManyTill = undefined
407407{-# INLINE parseIterate #-}
408408parseIterate
409409 :: MonadThrow m
410− => (b -> Parser m a b)
410+ => (b -> Parser a m b)
411411 -> b
412412 -> Stream m a
413413 -> Stream m b
core/src/Streamly/Internal/Data/Stream/StreamD/Eliminate.hs+2−2
@@ -142,7 +142,7 @@ newtype List a = List {getList :: [a]}
142142{-# INLINE_NORMAL parse #-}
143143parse
144144 :: MonadThrow m
145− => PRD.Parser m a b
145+ => PRD.Parser a m b
146146 -> Stream m a
147147 -> m b
148148parse parser strm = do
@@ -153,7 +153,7 @@ parse parser strm = do
153153{-# INLINE_NORMAL parseBreak #-}
154154parseBreak
155155 :: MonadThrow m
156− => PRD.Parser m a b
156+ => PRD.Parser a m b
157157 -> Stream m a
158158 -> m (b, Stream m a)
159159parseBreak (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
106106 --
107107 -- @
108108 -- 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
110110 -- @
111111
112112 -- ** Folding
@@ -1152,7 +1152,7 @@ data ParseChunksState x inpBuf st pst =
11521152{-# INLINE_NORMAL parseMany #-}
11531153parseMany
11541154 :: MonadThrow m
1155− => PRD.Parser m a b
1155+ => PRD.Parser a m b
11561156 -> Stream m a
11571157 -> Stream m b
11581158parseMany (PRD.Parser pstep initial extract) (Stream step state) =
@@ -1338,7 +1338,7 @@ data ConcatParseState b inpBuf st p m a =
13381338{-# INLINE_NORMAL parseIterate #-}
13391339parseIterate
13401340 :: MonadThrow m
1341− => (b -> PRD.Parser m a b)
1341+ => (b -> PRD.Parser a m b)
13421342 -> b
13431343 -> Stream m a
13441344 -> Stream m b
core/src/Streamly/Internal/Data/Stream/StreamK.hs+1−1
@@ -1025,7 +1025,7 @@ splitAt n ls
10251025{-# INLINE_NORMAL parseBreak #-}
10261026parseBreak
10271027 :: MonadThrow m
1028− => PR.Parser m a b
1028+ => PR.Parser a m b
10291029 -> Stream m a
10301030 -> m (b, Stream m a)
10311031parseBreak (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
7878-- We can measure if there is a signficant difference and if so we can add such
7979-- predicates to Streamly.Unicode.Parser.Latin1.
8080--
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
8282-- XXX Need to use the predicates from Unicode.Char module/unicode-data package
8383#define CHAR_PARSER(NAME, PREDICATE) NAME = Parser.satisfy Char.PREDICATE
8484#define CHAR_PARSER_DOC(PREDICATE) -- | Match any character that satisfies 'Char.PREDICATE'
@@ -168,13 +168,13 @@ CHAR_PARSER(asciiLower,isAsciiLower)
168168
169169-- | Match a specific character.
170170{-# INLINE char #-}
171−char :: MonadCatch m => Char -> Parser m Char Char
171+char :: MonadCatch m => Char -> Parser Char m Char
172172char c = Parser.satisfy (== c)
173173
174174-- XXX Case conversion may lead to change in number of chars
175175-- | Match a specific character ignoring case.
176176{-# INLINE charIgnoreCase #-}
177−charIgnoreCase :: MonadCatch m => Char -> Parser m Char Char
177+charIgnoreCase :: MonadCatch m => Char -> Parser Char m Char
178178charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
179179
180180--------------------------------------------------------------------------------
@@ -182,21 +182,21 @@ charIgnoreCase c = Parser.lmap Char.toLower (Parser.satisfy (== Char.toLower c))
182182--------------------------------------------------------------------------------
183183
184184-- | 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
186186string = Parser.listEq
187187
188188-- XXX Not accurate unicode case conversion
189189-- | 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
191191stringIgnoreCase s =
192192 Parser.lmap Char.toLower (Parser.listEq (map Char.toLower s))
193193
194194-- | Drop /zero/ or more white space characters.
195−dropSpace :: MonadCatch m => Parser m Char ()
195+dropSpace :: MonadCatch m => Parser Char m ()
196196dropSpace = Parser.dropWhile Char.isSpace
197197
198198-- | Drop /one/ or more white space characters.
199−dropSpace1 :: MonadCatch m => Parser m Char ()
199+dropSpace1 :: MonadCatch m => Parser Char m ()
200200dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
201201
202202--------------------------------------------------------------------------------
@@ -207,7 +207,7 @@ dropSpace1 = Parser.takeWhile1 Char.isSpace Fold.drain
207207--
208208-- | Parse and decode an unsigned integral decimal number.
209209{-# INLINE decimal #-}
210−decimal :: (MonadCatch m, Integral a) => Parser m Char a
210+decimal :: (MonadCatch m, Integral a) => Parser Char m a
211211decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
212212
213213 where
@@ -219,7 +219,7 @@ decimal = Parser.takeWhile1 Char.isDigit (Fold.foldl' step 0)
219219--
220220-- Note: This parser does not accept a leading @\"0x\"@ string.
221221{-# 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
223223hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
224224
225225 where
@@ -244,7 +244,7 @@ hexadecimal = Parser.takeWhile1 isHexDigit (Fold.foldl' step 0)
244244-- | Allow an optional leading @\'+\'@ or @\'-\'@ sign character before any
245245-- parser.
246246{-# 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
248248signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
249249
250250-- | Parse a 'Double'.
@@ -278,5 +278,5 @@ signed p = (negate <$> (char '-' *> p)) <|> (char '+' *> p) <|> p
278278-- \"Infinity\".
279279--
280280-- /Unimplemented/
281−double :: Parser m Char Double
281+double :: Parser Char m Double
282282double = undefined
core/src/Streamly/Internal/Unicode/Stream.hs+2−2
@@ -453,7 +453,7 @@ data UTF8CharDecodeState a
453453
454454{-# INLINE parseCharUtf8WithD #-}
455455parseCharUtf8WithD ::
456− MonadThrow m => CodingFailureMode -> ParserD.Parser m Word8 Char
456+ MonadThrow m => CodingFailureMode -> ParserD.Parser Word8 m Char
457457parseCharUtf8WithD cfm = ParserD.Parser (step' utf8d) initial extract
458458
459459 where
@@ -541,7 +541,7 @@ writeCharUtf8' = ParserD.toFold (parseCharUtf8WithD ErrorOnCodingFailure)
541541-- This needs to be investigated futher.
542542{-# INLINE parseCharUtf8With #-}
543543parseCharUtf8With ::
544− MonadCatch m => CodingFailureMode -> Parser.Parser m Word8 Char
544+ MonadCatch m => CodingFailureMode -> Parser.Parser Word8 m Char
545545parseCharUtf8With = ParserD.toParserK . parseCharUtf8WithD
546546
547547-- 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
6161 | StrVar String
6262 deriving (Show, Eq)
6363
64−haskellIdentifier :: MonadCatch m => Parser m Char String
64+haskellIdentifier :: MonadCatch m => Parser Char m String
6565haskellIdentifier =
6666 let p = Parser.alphaNum <|> Parser.char '\'' <|> Parser.char '_'
6767 in Parser.some p Fold.toList
6868
69−strParser :: MonadCatch m => Parser m Char [StrSegment]
69+strParser :: MonadCatch m => Parser Char m [StrSegment]
7070strParser = Parser.many content Fold.toList
7171
7272 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
2424 --
2525 -- @
2626 -- 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
2828 -- @
2929
3030 -- ** Generic Folding
@@ -383,7 +383,7 @@ refoldIterateM c i m = fromStreamD $ D.refoldIterateM c i (toStreamD m)
383383{-# INLINE parseMany #-}
384384parseMany
385385 :: (IsStream t, MonadThrow m)
386− => Parser m a b
386+ => Parser a m b
387387 -> t m a
388388 -> t m b
389389parseMany p m =
@@ -396,7 +396,7 @@ parseMany p m =
396396{-# INLINE parseManyD #-}
397397parseManyD
398398 :: (IsStream t, MonadThrow m)
399− => PRD.Parser m a b
399+ => PRD.Parser a m b
400400 -> t m a
401401 -> t m b
402402parseManyD p m =
@@ -410,7 +410,7 @@ parseManyD p m =
410410{-# INLINE parseSequence #-}
411411parseSequence
412412 :: -- (IsStream t, Monad m) =>
413− t m (Parser m a b)
413+ t m (Parser a m b)
414414 -> t m a
415415 -> t m b
416416parseSequence _f _m = undefined
@@ -428,8 +428,8 @@ parseSequence _f _m = undefined
428428{-# INLINE parseManyTill #-}
429429parseManyTill ::
430430 -- (IsStream t, MonadThrow m) =>
431− Parser m a b
432− -> Parser m a x
431+ Parser a m b
432+ -> Parser a m x
433433 -> t m a
434434 -> t m b
435435parseManyTill = undefined
@@ -450,7 +450,7 @@ parseManyTill = undefined
450450{-# INLINE parseIterate #-}
451451parseIterate
452452 :: (IsStream t, MonadThrow m)
453− => (b -> Parser m a b)
453+ => (b -> Parser a m b)
454454 -> b
455455 -> t m a
456456 -> t m b
src/Streamly/Internal/FileSystem/Event/Darwin.hs+1−1
@@ -489,7 +489,7 @@ data Event = Event
489489-- XXX should we use a magic in the header to avoid any issues due to
490490-- misalignment of records? Can that ever happen?
491491--
492−readOneEvent :: Parser IO Word8 Event
492+readOneEvent :: Parser Word8 IO Event
493493readOneEvent = do
494494 arr <- PR.takeEQ 24 (A.writeN 24)
495495 let arr1 = A.castUnsafe arr :: Array Word64
src/Streamly/Internal/FileSystem/Event/Linux.hs+1−1
@@ -799,7 +799,7 @@ data Event = Event
799799-- XXX We can perhaps use parseD monad instance for fusing with parseMany? Need
800800-- to measure the perf.
801801--
802−readOneEvent :: Config -> Watch -> Parser IO Word8 Event
802+readOneEvent :: Config -> Watch -> Parser Word8 IO Event
803803readOneEvent cfg wt@(Watch _ wdMap) = do
804804 let headerLen = sizeOf (undefined :: CInt) + 12
805805 arr <- PR.takeEQ headerLen (A.writeN headerLen)
test/Streamly/Test/Data/Parser.hs+2−2
@@ -259,7 +259,7 @@ takeGE =
259259nLessThanEqual0 ::
260260 ( Int
261261 -> FL.Fold (Either SomeException) Int [Int]
262− -> P.Parser (Either SomeException) Int [Int]
262+ -> P.Parser Int (Either SomeException) [Int]
263263 )
264264 -> (Int -> [Int] -> [Int])
265265 -> Property
@@ -765,7 +765,7 @@ data Event = Event
765765 , eventAbsPath :: A.Array Word8
766766 } deriving (Show, Ord, Eq)
767767
768−readOneEvent :: P.Parser IO Word8 Event
768+readOneEvent :: P.Parser Word8 IO Event
769769readOneEvent = do
770770 arr <- P.takeEQ 24 (A.writeN 24)
771771 let arr1 = A.castUnsafe arr :: A.Array Word64
test/Streamly/Test/Data/Parser/ParserD.hs+2−2
@@ -249,7 +249,7 @@ takeGE =
249249nLessThanEqual0 ::
250250 ( Int
251251 -> FL.Fold (Either SomeException) Int [Int]
252− -> P.Parser (Either SomeException) Int [Int]
252+ -> P.Parser Int (Either SomeException) [Int]
253253 )
254254 -> (Int -> [Int] -> [Int])
255255 -> Property
@@ -702,7 +702,7 @@ data Event = Event
702702 , eventAbsPath :: A.Array Word8
703703 } deriving (Show, Ord, Eq)
704704
705−readOneEvent :: P.Parser IO Word8 Event
705+readOneEvent :: P.Parser Word8 IO Event
706706readOneEvent = do
707707 arr <- P.takeEQ 24 (A.writeN 24)
708708 let arr1 = A.castUnsafe arr :: A.Array Word64