Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/src/Streamly/Internal/Data/Array/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ module Streamly.Internal.Data.Array.Stream
-- backtracking, StreamK at byte level would not be efficient.
-- parseBreak p = K.parseBreakChunks (ParserK.adaptC p)
, parseBreak
-- , parseBreakD
-- , foldManyChunks
-- , parseManyChunks
, K.parseBreakChunks
Expand Down Expand Up @@ -292,7 +291,7 @@ parseBreak ::
-> m (Either ParseError b, StreamK m (A.Array a))
{-
parseBreak p s =
fmap fromStreamD <$> parseBreakD (PRD.fromParserK p) (toStreamD s)
fmap fromStreamD <$> parseBreak (PRD.fromParserK p) (toStreamD s)
-}
parseBreak p = Array.parseBreak (Array.parserK p)

Expand Down Expand Up @@ -452,7 +451,7 @@ parseArr ::
=> ASF.Parser a m b
-> Stream m (A.Array a)
-> m (b, Stream m (A.Array a))
parseArr p s = fmap fromStreamD <$> parseBreakD p (toStreamD s)
parseArr p s = fmap fromStreamD <$> parseBreak p (toStreamD s)
-}

-- | Fold an array stream using the supplied array stream 'Fold'.
Expand Down
38 changes: 16 additions & 22 deletions core/src/Streamly/Internal/Data/Stream/Eliminate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ module Streamly.Internal.Data.Stream.Eliminate
(
-- * Running a Parser
parse
, parseD
, parseBreak
, parseBreakD

-- * Deconstruction
, uncons
Expand Down Expand Up @@ -58,10 +56,15 @@ module Streamly.Internal.Data.Stream.Eliminate
, stripPrefix
, stripSuffix
, stripSuffixUnbox

-- * Deprecated
, parseD
, parseBreakD
)
where

#include "inline.hs"
#include "deprecation.h"

import Control.Exception (assert)
import Control.Monad.IO.Class (MonadIO(..))
Expand Down Expand Up @@ -115,16 +118,8 @@ foldr1 f m = do
{-# ANN type List NoSpecConstr #-}
newtype List a = List {getList :: [a]}

-- | Run a 'Parse' over a stream.
{-# INLINE_NORMAL parseD #-}
parseD
:: Monad m
=> PRD.Parser a m b
-> Stream m a
-> m (Either ParseError b)
parseD parser strm = do
(b, _) <- parseBreakD parser strm
return b
-- XXX There is INLINE_NORMAL on parseD but INLINE [3] on parse
-- XXX There is INLINE on parseBreakD but INLINE_NORMAL on parseBreak

-- | Parse a stream using the supplied 'Parser'.
--
Expand All @@ -139,8 +134,11 @@ parseD parser strm = do
-- Note: @parse p@ is not the same as @head . parseMany p@ on an empty stream.
--
{-# INLINE [3] parse #-}
parse :: Monad m => PR.Parser a m b -> Stream m a -> m (Either ParseError b)
parse = parseD
parseD, parse :: Monad m => PR.Parser a m b -> Stream m a -> m (Either ParseError b)
parse parser strm = do
(b, _) <- parseBreak parser strm
return b
RENAME(parseD,parse)

-- XXX It may be a good idea to use constant sized chunks for backtracking. We
-- can take a byte stream but when we have to backtrack we create constant
Expand All @@ -150,13 +148,13 @@ parse = parseD
-- reducing bookkeeping work.

-- | Run a 'Parse' over a stream and return rest of the Stream.
{-# INLINE_NORMAL parseBreakD #-}
parseBreakD
{-# INLINE_NORMAL parseBreak #-}
parseBreakD, parseBreak
:: Monad m
=> PRD.Parser a m b
-> Stream m a
-> m (Either ParseError b, Stream m a)
parseBreakD (PRD.Parser pstep initial extract) stream@(Stream step state) = do
parseBreak (PRD.Parser pstep initial extract) stream@(Stream step state) = do
res <- initial
case res of
PRD.IPartial s -> go SPEC state (List []) s
Expand Down Expand Up @@ -336,11 +334,7 @@ parseBreakD (PRD.Parser pstep initial extract) stream@(Stream step state) = do
let src = Prelude.reverse $ getList buf
return (Left (ParseError err), fromList src)

-- | Parse a stream using the supplied 'Parser'.
--
{-# INLINE parseBreak #-}
parseBreak :: Monad m => PR.Parser a m b -> Stream m a -> m (Either ParseError b, Stream m a)
parseBreak = parseBreakD
RENAME(parseBreakD,parseBreak)

------------------------------------------------------------------------------
-- Specialized Folds
Expand Down
Loading