Skip to content

Commit 2d16756

Browse files
author
DDC
committed
Added lines - no tests yet
1 parent 39d0767 commit 2d16756

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

streamy-testsuite/lib/Test/PipesStreaming.hs

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import qualified Test.PipesStreaming.Streamy.Bytes as YB
1111

1212
import Data.Foldable hiding (concat)
1313
import qualified Data.ByteString as B
14+
import qualified Data.Text as T
1415
import Data.Monoid
1516
import Data.List.NonEmpty (NonEmpty(..))
1617
import Control.Applicative
@@ -138,3 +139,16 @@ testDelimitChunksOf = do
138139
(\_ -> [] :| [])
139140
0
140141

142+
textlines :: Stream T.Text IO r -> Groups T.Text IO r
143+
textlines =
144+
Y.delimit (\nl txt ->
145+
if T.null txt
146+
then (nl,pure [])
147+
else let nl' = T.last txt == '\n'
148+
in case (nl,T.lines txt) of
149+
(True,ls) -> (nl', [] :| map pure ls)
150+
(False,l:ls) -> (nl', [l] :| map pure ls)
151+
(_,[]) -> error "never happens")
152+
(\_ -> pure [])
153+
True
154+

streamy-testsuite/package.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ library test-pipes-streaming
3737
base >= 4.10 && < 4.11 ,
3838
transformers > 0.5 ,
3939
bytestring ,
40+
text >= 1.2 ,
4041
tasty >= 0.10.1.1 ,
4142
tasty-hunit >= 0.9.2 ,
4243
streamy-bytes-sig == 0.1.0.0

0 commit comments

Comments
 (0)