@@ -21,8 +21,7 @@ module Streamly.Internal.Data.Parser.ParserK.Type
2121 Step (..)
2222 , Input (..)
2323 , ParseResult (..)
24− , Parser (..)
25− , ParserK
24+ , ParserK (..)
2625 , fromParser
2726 -- , toParser
2827 , fromPure
@@ -111,7 +110,7 @@ instance Functor ParseResult where
111110-- input without a result or return a result with no further input to be
112111-- consumed.
113112--
114−newtype Parser a m b = MkParser
113+newtype ParserK a m b = MkParser
115114 { runParser :: forall r.
116115 -- Using "Input" in runParser is not necessary but it avoids making
117116 -- one more function call to get the input. This could be helpful
@@ -143,8 +142,6 @@ newtype Parser a m b = MkParser
143142 -> m (Step a m r)
144143 }
145144
146−type ParserK = Parser
147−
148145-------------------------------------------------------------------------------
149146-- Functor
150147-------------------------------------------------------------------------------
@@ -152,7 +149,7 @@ type ParserK = Parser
152149-- XXX rewrite this using ParserD, expose rmapM from ParserD.
153150-- | Maps a function over the output of the parser.
154151--
155−instance Functor m => Functor (Parser a m) where
152+instance Functor m => Functor (ParserK a m) where
156153 {-# INLINE fmap #-}
157154 fmap f parser = MkParser $ \k n st arr ->
158155 let k1 res = k (fmap f res)
@@ -169,7 +166,7 @@ instance Functor m => Functor (Parser a m) where
169166-- /Pre-release/
170167--
171168{-# INLINE fromPure #-}
172−fromPure :: b -> Parser a m b
169+fromPure :: b -> ParserK a m b
173170fromPure b = MkParser $ \k n st arr -> k (Success n b) st arr
174171
175172-- | See 'Streamly.Internal.Data.Parser.fromEffect'.
@@ -177,7 +174,7 @@ fromPure b = MkParser $ \k n st arr -> k (Success n b) st arr
177174-- /Pre-release/
178175--
179176{-# INLINE fromEffect #-}
180−fromEffect :: Monad m => m b -> Parser a m b
177+fromEffect :: Monad m => m b -> ParserK a m b
181178fromEffect eff =
182179 MkParser $ \k n st arr -> eff >>= \b -> k (Success n b) st arr
183180
@@ -185,7 +182,7 @@ fromEffect eff =
185182-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.splitWith'
186183-- when fusion is important.
187184--
188−instance Monad m => Applicative (Parser a m) where
185+instance Monad m => Applicative (ParserK a m) where
189186 {-# INLINE pure #-}
190187 pure = fromPure
191188
@@ -222,7 +219,7 @@ instance Monad m => Applicative (Parser a m) where
222219-- /Pre-release/
223220--
224221{-# INLINE die #-}
225−die :: String -> Parser a m b
222+die :: String -> ParserK a m b
226223die err = MkParser (\k n st arr -> k (Failure n err) st arr)
227224
228225-- | Monad composition can be used for lookbehind parsers, we can make the
@@ -267,7 +264,7 @@ die err = MkParser (\k n st arr -> k (Failure n err) st arr)
267264-- does not fuse, use 'Streamly.Internal.Data.Parser.concatMap' when you need
268265-- fusion.
269266--
270−instance Monad m => Monad (Parser a m) where
267+instance Monad m => Monad (ParserK a m) where
271268 {-# INLINE return #-}
272269 return = pure
273270
@@ -286,11 +283,11 @@ instance Monad m => Monad (Parser a m) where
286283 {-# INLINE fail #-}
287284 fail = die
288285#endif
289−instance Monad m => Fail.MonadFail (Parser a m) where
286+instance Monad m => Fail.MonadFail (ParserK a m) where
290287 {-# INLINE fail #-}
291288 fail = die
292289
293−instance MonadIO m => MonadIO (Parser a m) where
290+instance MonadIO m => MonadIO (ParserK a m) where
294291 {-# INLINE liftIO #-}
295292 liftIO = fromEffect . liftIO
296293
@@ -311,7 +308,7 @@ instance MonadIO m => MonadIO (Parser a m) where
311308-- does not fuse, use 'Streamly.Internal.Data.Parser.alt' when you need
312309-- fusion.
313310--
314−instance Monad m => Alternative (Parser a m) where
311+instance Monad m => Alternative (ParserK a m) where
315312 {-# INLINE empty #-}
316313 empty = die "empty"
317314
@@ -344,7 +341,7 @@ instance Monad m => Alternative (Parser a m) where
344341-- | 'mzero' is same as 'empty', it aborts the parser. 'mplus' is same as
345342-- '<|>', it selects the first succeeding parser.
346343--
347−instance Monad m => MonadPlus (Parser a m) where
344+instance Monad m => MonadPlus (ParserK a m) where
348345 {-# INLINE mzero #-}
349346 mzero = die "mzero"
350347
@@ -352,7 +349,7 @@ instance Monad m => MonadPlus (Parser a m) where
352349 mplus = (<|>)
353350
354351{-
355−instance MonadTrans (Parser a) where
352+instance MonadTrans (ParserK a) where
356353 {-# INLINE lift #-}
357354 lift = fromEffect
358355-}
@@ -521,7 +518,7 @@ parserDone _ _ _ = error "Bug: toParser: called with input"
521518-- /Pre-release/
522519--
523520{-# INLINE_LATE toParser #-}
524−toParser :: Monad m => Parser a m b -> ParserD.Parser a m b
521+toParser :: Monad m => ParserK a m b -> ParserD.Parser a m b
525522toParser parser = ParserD.Parser step initial extract
526523
527524 where