on master help sign in
Move Streamly.Unicode to streamly-core
182edfdRanjeet Kumar Ranjan
.hlint.ignore+1−1
@@ -1,7 +1,7 @@
1core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
1core/src/Streamly/Internal/Data/Stream/StreamK/Type.hs
2core/src/Streamly/Internal/Data/Pipe/Type.hs
2core/src/Streamly/Internal/Data/Pipe/Type.hs
3+core/src/Streamly/Internal/Unicode/Stream.hs
3src/Streamly/Internal/Data/SmallArray/Type.hs
4src/Streamly/Internal/Data/SmallArray/Type.hs
4−src/Streamly/Internal/Unicode/Stream.hs
5test/Streamly/Test/Data/Array.hs
5test/Streamly/Test/Data/Array.hs
6test/Streamly/Test/Data/Parser.hs
6test/Streamly/Test/Data/Parser.hs
7test/Streamly/Test/Data/Parser/ParserD.hs
7test/Streamly/Test/Data/Parser/ParserD.hs
cabal.project.packdiff+1−1
@@ -5,7 +5,7 @@ packages:
5source-repository-package
5source-repository-package
6 type: git
6 type: git
7 location: https://github.com/composewell/packdiff.git
7 location: https://github.com/composewell/packdiff.git
8− tag: 45cdca157e7159b8dd4261b3616fe7fa4200b967
8+ tag: 8b5d35b72b8ba3c9fb34f16e30d9d58f22b78f3e
9
9
10source-repository-package
10source-repository-package
11 type: git
11 type: git
src/Streamly/Internal/Unicode/Array/Char.hs → core/src/Streamly/Internal/Unicode/Array/Char.hsrenamed+6−7
@@ -18,9 +18,8 @@ module Streamly.Internal.Unicode.Array.Char
18where
18where
19
19
20import Control.Monad.IO.Class (MonadIO)
20import Control.Monad.IO.Class (MonadIO)
21−import Streamly.Data.Array.Unboxed (Array)
21+import Streamly.Data.Stream (Stream)
22−import Streamly.Internal.Data.Stream.IsStream (IsStream)
22+import Streamly.Internal.Data.Array.Unboxed (Array)
23−import Streamly.Prelude (MonadAsync)
24
23
25import qualified Streamly.Data.Array.Unboxed as A
24import qualified Streamly.Data.Array.Unboxed as A
26import qualified Streamly.Internal.Unicode.Stream as S
25import qualified Streamly.Internal.Unicode.Stream as S
@@ -43,7 +42,7 @@ import Prelude hiding (String, lines, words, unlines, unwords)
43-- ["lines","this","string","",""]
42-- ["lines","this","string","",""]
44--
43--
45{-# INLINE lines #-}
44{-# INLINE lines #-}
46−lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
45+lines :: (MonadIO m) => Stream m Char -> Stream m (Array Char)
47lines = S.lines A.write
46lines = S.lines A.write
48
47
49-- | Break a string up into a stream of strings, which were delimited
48-- | Break a string up into a stream of strings, which were delimited
@@ -55,7 +54,7 @@ lines = S.lines A.write
55-- ["A","newline","is","considered","white","space?"]
54-- ["A","newline","is","considered","white","space?"]
56--
55--
57{-# INLINE words #-}
56{-# INLINE words #-}
58−words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
57+words :: (MonadIO m) => Stream m Char -> Stream m (Array Char)
59words = S.words A.write
58words = S.words A.write
60
59
61-- | Flattens the stream of @Array Char@, after appending a terminating
60-- | Flattens the stream of @Array Char@, after appending a terminating
@@ -72,7 +71,7 @@ words = S.words A.write
72--
71--
73-- > unlines . lines /= id
72-- > unlines . lines /= id
74{-# INLINE unlines #-}
73{-# INLINE unlines #-}
75−unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
74+unlines :: (MonadIO m) => Stream m (Array Char) -> Stream m Char
76unlines = S.unlines A.read
75unlines = S.unlines A.read
77
76
78-- | Flattens the stream of @Array Char@, after appending a separating
77-- | Flattens the stream of @Array Char@, after appending a separating
@@ -89,5 +88,5 @@ unlines = S.unlines A.read
89--
88--
90-- > unwords . words /= id
89-- > unwords . words /= id
91{-# INLINE unwords #-}
90{-# INLINE unwords #-}
92−unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
91+unwords :: (MonadIO m) => Stream m (Array Char) -> Stream m Char
93unwords = S.unwords A.read
92unwords = S.unwords A.read
src/Streamly/Internal/Unicode/Char/Parser.hs → core/src/Streamly/Internal/Unicode/Char/Parser.hsrenamed

The content is the same.

src/Streamly/Internal/Unicode/Stream.hs → core/src/Streamly/Internal/Unicode/Stream.hsrenamed+58−64
@@ -103,14 +103,12 @@ import GHC.Exts (Addr#)
103import GHC.IO.Encoding.Failure (isSurrogate)
103import GHC.IO.Encoding.Failure (isSurrogate)
104import GHC.Ptr (Ptr (..), plusPtr)
104import GHC.Ptr (Ptr (..), plusPtr)
105import System.IO.Unsafe (unsafePerformIO)
105import System.IO.Unsafe (unsafePerformIO)
106−import Streamly.Internal.Data.Array.Unboxed (Array)
106+import Streamly.Internal.Data.Array.Unboxed.Type (Array(..))
107import Streamly.Internal.Data.Array.Unboxed.Mut.Type (MutableByteArray)
107import Streamly.Internal.Data.Array.Unboxed.Mut.Type (MutableByteArray)
108import Streamly.Internal.Data.Fold (Fold)
108import Streamly.Internal.Data.Fold (Fold)
109−import Streamly.Internal.Data.Stream.IsStream.Type
109+import Streamly.Internal.Data.Stream (Stream, fromStreamD, toStreamD)
110− (IsStream, fromStreamD, toStreamD, adapt)
111−import Streamly.Internal.Data.Stream (Stream)
112import Streamly.Internal.Data.Stream.StreamD (Step (..))
110import Streamly.Internal.Data.Stream.StreamD (Step (..))
113−import Streamly.Internal.Data.SVar (adaptState)
111+import Streamly.Internal.Data.SVar.Type (adaptState)
114import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
112import Streamly.Internal.Data.Tuple.Strict (Tuple'(..))
115import Streamly.Internal.Data.Unboxed (peekWith)
113import Streamly.Internal.Data.Unboxed (peekWith)
116import Streamly.Internal.Data.Unfold.Type (Unfold(..))
114import Streamly.Internal.Data.Unfold.Type (Unfold(..))
@@ -118,14 +116,10 @@ import Streamly.Internal.System.IO (unsafeInlineIO)
118
116
119import qualified Streamly.Data.Fold as Fold
117import qualified Streamly.Data.Fold as Fold
120import qualified Streamly.Data.Unfold as Unfold
118import qualified Streamly.Data.Unfold as Unfold
119+import qualified Streamly.Internal.Data.Array.Unboxed.Type as Array
121import qualified Streamly.Internal.Data.Parser as Parser (Parser)
120import qualified Streamly.Internal.Data.Parser as Parser (Parser)
122import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
121import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
123− (Parser(..), Step(..), Initial(..), toParserK, toFold)
124−import qualified Streamly.Internal.Data.Stream as Stream (fromByteStr#)
122+import qualified Streamly.Internal.Data.Stream as Stream
125−import qualified Streamly.Internal.Data.Stream.Serial as Serial
126−import qualified Streamly.Data.Array.Unboxed as Array
127−import qualified Streamly.Internal.Data.Array.Unboxed.Type as A (Array (..))
128−import qualified Streamly.Internal.Data.Stream.IsStream as S
129import qualified Streamly.Internal.Data.Stream.StreamD as D
123import qualified Streamly.Internal.Data.Stream.StreamD as D
130
124
131import Prelude hiding (lines, words, unlines, unwords)
125import Prelude hiding (lines, words, unlines, unwords)
@@ -150,8 +144,8 @@ import Prelude hiding (lines, words, unlines, unwords)
150--
144--
151-- @since 0.8.0
145-- @since 0.8.0
152{-# INLINE decodeLatin1 #-}
146{-# INLINE decodeLatin1 #-}
153−decodeLatin1 :: (IsStream t, Monad m) => t m Word8 -> t m Char
147+decodeLatin1 :: (Monad m) => Stream m Word8 -> Stream m Char
154−decodeLatin1 = S.map (unsafeChr . fromIntegral)
148+decodeLatin1 = fmap (unsafeChr . fromIntegral)
155
149
156-------------------------------------------------------------------------------
150-------------------------------------------------------------------------------
157-- Latin1 encoding
151-- Latin1 encoding
@@ -163,8 +157,8 @@ decodeLatin1 = S.map (unsafeChr . fromIntegral)
163--
157--
164-- @since 0.8.0
158-- @since 0.8.0
165{-# INLINE encodeLatin1' #-}
159{-# INLINE encodeLatin1' #-}
166−encodeLatin1' :: (IsStream t, Monad m) => t m Char -> t m Word8
160+encodeLatin1' :: (Monad m) => Stream m Char -> Stream m Word8
167−encodeLatin1' = S.map convert
161+encodeLatin1' = fmap convert
168 where
162 where
169 convert c =
163 convert c =
170 let codepoint = ord c
164 let codepoint = ord c
@@ -185,21 +179,21 @@ encodeLatin1' = S.map convert
185--
179--
186-- /Since: 0.8.0 (Lenient Behaviour)/
180-- /Since: 0.8.0 (Lenient Behaviour)/
187{-# INLINE encodeLatin1 #-}
181{-# INLINE encodeLatin1 #-}
188−encodeLatin1 :: (IsStream t, Monad m) => t m Char -> t m Word8
182+encodeLatin1 :: (Monad m) => Stream m Char -> Stream m Word8
189−encodeLatin1 = S.map (fromIntegral . ord)
183+encodeLatin1 = fmap (fromIntegral . ord)
190
184
191-- | Like 'encodeLatin1' but drops the input characters beyond 255.
185-- | Like 'encodeLatin1' but drops the input characters beyond 255.
192--
186--
193-- @since 0.8.0
187-- @since 0.8.0
194{-# INLINE encodeLatin1_ #-}
188{-# INLINE encodeLatin1_ #-}
195−encodeLatin1_ :: (IsStream t, Monad m) => t m Char -> t m Word8
189+encodeLatin1_ :: (Monad m) => Stream m Char -> Stream m Word8
196−encodeLatin1_ = S.map (fromIntegral . ord) . S.filter (<= chr 255)
190+encodeLatin1_ = fmap (fromIntegral . ord) . Stream.filter (<= chr 255)
197
191
198-- | Same as 'encodeLatin1'
192-- | Same as 'encodeLatin1'
199--
193--
200{-# DEPRECATED encodeLatin1Lax "Please use 'encodeLatin1' instead" #-}
194{-# DEPRECATED encodeLatin1Lax "Please use 'encodeLatin1' instead" #-}
201{-# INLINE encodeLatin1Lax #-}
195{-# INLINE encodeLatin1Lax #-}
202−encodeLatin1Lax :: (IsStream t, Monad m) => t m Char -> t m Word8
196+encodeLatin1Lax :: (Monad m) => Stream m Char -> Stream m Word8
203encodeLatin1Lax = encodeLatin1
197encodeLatin1Lax = encodeLatin1
204
198
205-------------------------------------------------------------------------------
199-------------------------------------------------------------------------------
@@ -430,8 +424,8 @@ decodeUtf8EitherD = resumeDecodeUtf8EitherD 0 0
430--
424--
431-- /Pre-release/
425-- /Pre-release/
432{-# INLINE decodeUtf8Either #-}
426{-# INLINE decodeUtf8Either #-}
433−decodeUtf8Either :: (Monad m, IsStream t)
427+decodeUtf8Either :: (Monad m)
434− => t m Word8 -> t m (Either DecodeError Char)
428+ => Stream m Word8 -> Stream m (Either DecodeError Char)
435decodeUtf8Either = fromStreamD . decodeUtf8EitherD . toStreamD
429decodeUtf8Either = fromStreamD . decodeUtf8EitherD . toStreamD
436
430
437-- |
431-- |
@@ -439,11 +433,11 @@ decodeUtf8Either = fromStreamD . decodeUtf8EitherD . toStreamD
439-- /Pre-release/
433-- /Pre-release/
440{-# INLINE resumeDecodeUtf8Either #-}
434{-# INLINE resumeDecodeUtf8Either #-}
441resumeDecodeUtf8Either
435resumeDecodeUtf8Either
442− :: (Monad m, IsStream t)
436+ :: (Monad m)
443 => DecodeState
437 => DecodeState
444 -> CodePoint
438 -> CodePoint
445− -> t m Word8
439+ -> Stream m Word8
446− -> t m (Either DecodeError Char)
440+ -> Stream m (Either DecodeError Char)
447resumeDecodeUtf8Either st cp =
441resumeDecodeUtf8Either st cp =
448 fromStreamD . resumeDecodeUtf8EitherD st cp . toStreamD
442 fromStreamD . resumeDecodeUtf8EitherD st cp . toStreamD
449
443
@@ -663,7 +657,7 @@ decodeUtf8D = decodeUtf8WithD TransliterateCodingFailure
663--
657--
664-- /Since: 0.8.0 (Lenient Behaviour)/
658-- /Since: 0.8.0 (Lenient Behaviour)/
665{-# INLINE decodeUtf8 #-}
659{-# INLINE decodeUtf8 #-}
666−decodeUtf8 :: (Monad m, IsStream t) => t m Word8 -> t m Char
660+decodeUtf8 :: (Monad m) => Stream m Word8 -> Stream m Char
667decodeUtf8 = fromStreamD . decodeUtf8D . toStreamD
661decodeUtf8 = fromStreamD . decodeUtf8D . toStreamD
668
662
669{-# INLINE decodeUtf8D' #-}
663{-# INLINE decodeUtf8D' #-}
@@ -675,7 +669,7 @@ decodeUtf8D' = decodeUtf8WithD ErrorOnCodingFailure
675--
669--
676-- @since 0.8.0
670-- @since 0.8.0
677{-# INLINE decodeUtf8' #-}
671{-# INLINE decodeUtf8' #-}
678−decodeUtf8' :: (Monad m, IsStream t) => t m Word8 -> t m Char
672+decodeUtf8' :: (Monad m) => Stream m Word8 -> Stream m Char
679decodeUtf8' = fromStreamD . decodeUtf8D' . toStreamD
673decodeUtf8' = fromStreamD . decodeUtf8D' . toStreamD
680
674
681{-# INLINE decodeUtf8D_ #-}
675{-# INLINE decodeUtf8D_ #-}
@@ -687,14 +681,14 @@ decodeUtf8D_ = decodeUtf8WithD DropOnCodingFailure
687--
681--
688-- @since 0.8.0
682-- @since 0.8.0
689{-# INLINE decodeUtf8_ #-}
683{-# INLINE decodeUtf8_ #-}
690−decodeUtf8_ :: (Monad m, IsStream t) => t m Word8 -> t m Char
684+decodeUtf8_ :: (Monad m) => Stream m Word8 -> Stream m Char
691decodeUtf8_ = fromStreamD . decodeUtf8D_ . toStreamD
685decodeUtf8_ = fromStreamD . decodeUtf8D_ . toStreamD
692
686
693-- | Same as 'decodeUtf8'
687-- | Same as 'decodeUtf8'
694--
688--
695{-# DEPRECATED decodeUtf8Lax "Please use 'decodeUtf8' instead" #-}
689{-# DEPRECATED decodeUtf8Lax "Please use 'decodeUtf8' instead" #-}
696{-# INLINE decodeUtf8Lax #-}
690{-# INLINE decodeUtf8Lax #-}
697−decodeUtf8Lax :: (IsStream t, Monad m) => t m Word8 -> t m Char
691+decodeUtf8Lax :: (Monad m) => Stream m Word8 -> Stream m Char
698decodeUtf8Lax = decodeUtf8
692decodeUtf8Lax = decodeUtf8
699
693
700-------------------------------------------------------------------------------
694-------------------------------------------------------------------------------
@@ -726,7 +720,7 @@ data FlattenState s a
726decodeUtf8ArraysWithD ::
720decodeUtf8ArraysWithD ::
727 MonadIO m
721 MonadIO m
728 => CodingFailureMode
722 => CodingFailureMode
729− -> D.Stream m (A.Array Word8)
723+ -> D.Stream m (Array Word8)
730 -> D.Stream m Char
724 -> D.Stream m Char
731decodeUtf8ArraysWithD cfm (D.Stream step state) =
725decodeUtf8ArraysWithD cfm (D.Stream step state) =
732 D.Stream (step' utf8d) (OuterLoop state Nothing)
726 D.Stream (step' utf8d) (OuterLoop state Nothing)
@@ -751,7 +745,7 @@ decodeUtf8ArraysWithD cfm (D.Stream step state) =
751 r <- step (adaptState gst) st
745 r <- step (adaptState gst) st
752 return $
746 return $
753 case r of
747 case r of
754− Yield A.Array {..} s ->
748+ Yield Array {..} s ->
755 Skip (InnerLoopDecodeInit s arrContents arrStart arrEnd)
749 Skip (InnerLoopDecodeInit s arrContents arrStart arrEnd)
756 Skip s -> Skip (OuterLoop s Nothing)
750 Skip s -> Skip (OuterLoop s Nothing)
757 Stop -> Skip D
751 Stop -> Skip D
@@ -759,7 +753,7 @@ decodeUtf8ArraysWithD cfm (D.Stream step state) =
759 r <- step (adaptState gst) st
753 r <- step (adaptState gst) st
760 return $
754 return $
761 case r of
755 case r of
762− Yield A.Array {..} s ->
756+ Yield Array {..} s ->
763 Skip (InnerLoopDecoding s arrContents arrStart arrEnd ds cp)
757 Skip (InnerLoopDecoding s arrContents arrStart arrEnd ds cp)
764 Skip s -> Skip (OuterLoop s dst)
758 Skip s -> Skip (OuterLoop s dst)
765 Stop -> Skip inputUnderflow
759 Stop -> Skip inputUnderflow
@@ -828,7 +822,7 @@ decodeUtf8ArraysWithD cfm (D.Stream step state) =
828{-# INLINE decodeUtf8ArraysD #-}
822{-# INLINE decodeUtf8ArraysD #-}
829decodeUtf8ArraysD ::
823decodeUtf8ArraysD ::
830 MonadIO m
824 MonadIO m
831− => D.Stream m (A.Array Word8)
825+ => D.Stream m (Array Word8)
832 -> D.Stream m Char
826 -> D.Stream m Char
833decodeUtf8ArraysD = decodeUtf8ArraysWithD TransliterateCodingFailure
827decodeUtf8ArraysD = decodeUtf8ArraysWithD TransliterateCodingFailure
834
828
@@ -837,14 +831,14 @@ decodeUtf8ArraysD = decodeUtf8ArraysWithD TransliterateCodingFailure
837-- /Pre-release/
831-- /Pre-release/
838{-# INLINE decodeUtf8Arrays #-}
832{-# INLINE decodeUtf8Arrays #-}
839decodeUtf8Arrays ::
833decodeUtf8Arrays ::
840− (MonadIO m, IsStream t) => t m (Array Word8) -> t m Char
834+ (MonadIO m) => Stream m (Array Word8) -> Stream m Char
841decodeUtf8Arrays =
835decodeUtf8Arrays =
842 fromStreamD . decodeUtf8ArraysD . toStreamD
836 fromStreamD . decodeUtf8ArraysD . toStreamD
843
837
844{-# INLINE decodeUtf8ArraysD' #-}
838{-# INLINE decodeUtf8ArraysD' #-}
845decodeUtf8ArraysD' ::
839decodeUtf8ArraysD' ::
846 MonadIO m
840 MonadIO m
847− => D.Stream m (A.Array Word8)
841+ => D.Stream m (Array Word8)
848 -> D.Stream m Char
842 -> D.Stream m Char
849decodeUtf8ArraysD' = decodeUtf8ArraysWithD ErrorOnCodingFailure
843decodeUtf8ArraysD' = decodeUtf8ArraysWithD ErrorOnCodingFailure
850
844
@@ -852,13 +846,13 @@ decodeUtf8ArraysD' = decodeUtf8ArraysWithD ErrorOnCodingFailure
852--
846--
853-- /Pre-release/
847-- /Pre-release/
854{-# INLINE decodeUtf8Arrays' #-}
848{-# INLINE decodeUtf8Arrays' #-}
855−decodeUtf8Arrays' :: (MonadIO m, IsStream t) => t m (Array Word8) -> t m Char
849+decodeUtf8Arrays' :: (MonadIO m) => Stream m (Array Word8) -> Stream m Char
856decodeUtf8Arrays' = fromStreamD . decodeUtf8ArraysD' . toStreamD
850decodeUtf8Arrays' = fromStreamD . decodeUtf8ArraysD' . toStreamD
857
851
858{-# INLINE decodeUtf8ArraysD_ #-}
852{-# INLINE decodeUtf8ArraysD_ #-}
859decodeUtf8ArraysD_ ::
853decodeUtf8ArraysD_ ::
860 MonadIO m
854 MonadIO m
861− => D.Stream m (A.Array Word8)
855+ => D.Stream m (Array Word8)
862 -> D.Stream m Char
856 -> D.Stream m Char
863decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
857decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
864
858
@@ -867,7 +861,7 @@ decodeUtf8ArraysD_ = decodeUtf8ArraysWithD DropOnCodingFailure
867-- /Pre-release/
861-- /Pre-release/
868{-# INLINE decodeUtf8Arrays_ #-}
862{-# INLINE decodeUtf8Arrays_ #-}
869decodeUtf8Arrays_ ::
863decodeUtf8Arrays_ ::
870− (MonadIO m, IsStream t) => t m (Array Word8) -> t m Char
864+ (MonadIO m) => Stream m (Array Word8) -> Stream m Char
871decodeUtf8Arrays_ =
865decodeUtf8Arrays_ =
872 fromStreamD . decodeUtf8ArraysD_ . toStreamD
866 fromStreamD . decodeUtf8ArraysD_ . toStreamD
873
867
@@ -943,7 +937,7 @@ encodeUtf8D' = D.unfoldMany readCharUtf8'
943--
937--
944-- @since 0.8.0
938-- @since 0.8.0
945{-# INLINE encodeUtf8' #-}
939{-# INLINE encodeUtf8' #-}
946−encodeUtf8' :: (Monad m, IsStream t) => t m Char -> t m Word8
940+encodeUtf8' :: (Monad m) => Stream m Char -> Stream m Word8
947encodeUtf8' = fromStreamD . encodeUtf8D' . toStreamD
941encodeUtf8' = fromStreamD . encodeUtf8D' . toStreamD
948
942
949{-# INLINE_NORMAL readCharUtf8 #-}
943{-# INLINE_NORMAL readCharUtf8 #-}
@@ -965,7 +959,7 @@ encodeUtf8D = D.unfoldMany readCharUtf8
965--
959--
966-- /Since: 0.8.0 (Lenient Behaviour)/
960-- /Since: 0.8.0 (Lenient Behaviour)/
967{-# INLINE encodeUtf8 #-}
961{-# INLINE encodeUtf8 #-}
968−encodeUtf8 :: (Monad m, IsStream t) => t m Char -> t m Word8
962+encodeUtf8 :: (Monad m) => Stream m Char -> Stream m Word8
969encodeUtf8 = fromStreamD . encodeUtf8D . toStreamD
963encodeUtf8 = fromStreamD . encodeUtf8D . toStreamD
970
964
971{-# INLINE_NORMAL readCharUtf8_ #-}
965{-# INLINE_NORMAL readCharUtf8_ #-}
@@ -981,14 +975,14 @@ encodeUtf8D_ = D.unfoldMany readCharUtf8_
981--
975--
982-- @since 0.8.0
976-- @since 0.8.0
983{-# INLINE encodeUtf8_ #-}
977{-# INLINE encodeUtf8_ #-}
984−encodeUtf8_ :: (Monad m, IsStream t) => t m Char -> t m Word8
978+encodeUtf8_ :: (Monad m) => Stream m Char -> Stream m Word8
985encodeUtf8_ = fromStreamD . encodeUtf8D_ . toStreamD
979encodeUtf8_ = fromStreamD . encodeUtf8D_ . toStreamD
986
980
987-- | Same as 'encodeUtf8'
981-- | Same as 'encodeUtf8'
988--
982--
989{-# DEPRECATED encodeUtf8Lax "Please use 'encodeUtf8' instead" #-}
983{-# DEPRECATED encodeUtf8Lax "Please use 'encodeUtf8' instead" #-}
990{-# INLINE encodeUtf8Lax #-}
984{-# INLINE encodeUtf8Lax #-}
991−encodeUtf8Lax :: (IsStream t, Monad m) => t m Char -> t m Word8
985+encodeUtf8Lax :: (Monad m) => Stream m Char -> Stream m Word8
992encodeUtf8Lax = encodeUtf8
986encodeUtf8Lax = encodeUtf8
993
987
994-------------------------------------------------------------------------------
988-------------------------------------------------------------------------------
@@ -1024,27 +1018,27 @@ encodeObject :: MonadIO m =>
1024 -> Unfold m a Char
1018 -> Unfold m a Char
1025 -> a
1019 -> a
1026 -> m (Array Word8)
1020 -> m (Array Word8)
1027−encodeObject encode u = S.fold Array.write . encode . S.unfold u
1021+encodeObject encode u = Stream.fold Array.write . encode . Stream.unfold u
1028
1022
1029-- | Encode a stream of container objects using the supplied encoding scheme.
1023-- | Encode a stream of container objects using the supplied encoding scheme.
1030-- Each object is encoded as an @Array Word8@.
1024-- Each object is encoded as an @Array Word8@.
1031--
1025--
1032-- /Internal/
1026-- /Internal/
1033{-# INLINE encodeObjects #-}
1027{-# INLINE encodeObjects #-}
1034−encodeObjects :: (MonadIO m, IsStream t) =>
1028+encodeObjects :: (MonadIO m) =>
1035 (Stream m Char -> Stream m Word8)
1029 (Stream m Char -> Stream m Word8)
1036 -> Unfold m a Char
1030 -> Unfold m a Char
1037− -> t m a
1031+ -> Stream m a
1038− -> t m (Array Word8)
1032+ -> Stream m (Array Word8)
1039−encodeObjects encode u = adapt . Serial.mapM (encodeObject encode u) . adapt
1033+encodeObjects encode u = Stream.mapM (encodeObject encode u)
1040
1034
1041-- | Encode a stream of 'String' using the supplied encoding scheme. Each
1035-- | Encode a stream of 'String' using the supplied encoding scheme. Each
1042-- string is encoded as an @Array Word8@.
1036-- string is encoded as an @Array Word8@.
1043--
1037--
1044-- @since 0.8.0
1038-- @since 0.8.0
1045{-# INLINE encodeStrings #-}
1039{-# INLINE encodeStrings #-}
1046−encodeStrings :: (MonadIO m, IsStream t) =>
1040+encodeStrings :: (MonadIO m) =>
1047− (Stream m Char -> Stream m Word8) -> t m String -> t m (Array Word8)
1041+ (Stream m Char -> Stream m Word8) -> Stream m String -> Stream m (Array Word8)
1048encodeStrings encode = encodeObjects encode Unfold.fromList
1042encodeStrings encode = encodeObjects encode Unfold.fromList
1049
1043
1050{-
1044{-
@@ -1052,21 +1046,21 @@ encodeStrings encode = encodeObjects encode Unfold.fromList
1052-- Utility operations on strings
1046-- Utility operations on strings
1053-------------------------------------------------------------------------------
1047-------------------------------------------------------------------------------
1054
1048
1055−strip :: IsStream t => t m Char -> t m Char
1049+strip :: IsStream t => Stream m Char -> Stream m Char
1056strip = undefined
1050strip = undefined
1057
1051
1058−stripTail :: IsStream t => t m Char -> t m Char
1052+stripTail :: IsStream t => Stream m Char -> Stream m Char
1059stripTail = undefined
1053stripTail = undefined
1060-}
1054-}
1061
1055
1062-- | Remove leading whitespace from a string.
1056-- | Remove leading whitespace from a string.
1063--
1057--
1064−-- > stripHead = S.dropWhile isSpace
1058+-- > stripHead = Stream.dropWhile isSpace
1065--
1059--
1066-- /Pre-release/
1060-- /Pre-release/
1067{-# INLINE stripHead #-}
1061{-# INLINE stripHead #-}
1068−stripHead :: (Monad m, IsStream t) => t m Char -> t m Char
1062+stripHead :: (Monad m) => Stream m Char -> Stream m Char
1069−stripHead = S.dropWhile isSpace
1063+stripHead = Stream.dropWhile isSpace
1070
1064
1071-- | Fold each line of the stream using the supplied 'Fold'
1065-- | Fold each line of the stream using the supplied 'Fold'
1072-- and stream the result.
1066-- and stream the result.
@@ -1074,12 +1068,12 @@ stripHead = S.dropWhile isSpace
1074-- >>> Stream.toList $ lines Fold.toList (Stream.fromList "lines\nthis\nstring\n\n\n")
1068-- >>> Stream.toList $ lines Fold.toList (Stream.fromList "lines\nthis\nstring\n\n\n")
1075-- ["lines","this","string","",""]
1069-- ["lines","this","string","",""]
1076--
1070--
1077−-- > lines = S.splitOnSuffix (== '\n')
1071+-- > lines = Stream.splitOnSuffix (== '\n')
1078--
1072--
1079-- /Pre-release/
1073-- /Pre-release/
1080{-# INLINE lines #-}
1074{-# INLINE lines #-}
1081−lines :: (Monad m, IsStream t) => Fold m Char b -> t m Char -> t m b
1075+lines :: (Monad m) => Fold m Char b -> Stream m Char -> Stream m b
1082−lines = S.splitOnSuffix (== '\n')
1076+lines f = Stream.foldMany (Fold.takeEndBy_ (== '\n') f)
1083
1077
1084#if !MIN_VERSION_base(4,17,0)
1078#if !MIN_VERSION_base(4,17,0)
1085foreign import ccall unsafe "u_iswspace"
1079foreign import ccall unsafe "u_iswspace"
@@ -1105,12 +1099,12 @@ isSpace c
1105-- >>> Stream.toList $ words Fold.toList (Stream.fromList "fold these words")
1099-- >>> Stream.toList $ words Fold.toList (Stream.fromList "fold these words")
1106-- ["fold","these","words"]
1100-- ["fold","these","words"]
1107--
1101--
1108−-- > words = S.wordsBy isSpace
1102+-- > words = Stream.wordsBy isSpace
1109--
1103--
1110-- /Pre-release/
1104-- /Pre-release/
1111{-# INLINE words #-}
1105{-# INLINE words #-}
1112−words :: (Monad m, IsStream t) => Fold m Char b -> t m Char -> t m b
1106+words :: (Monad m) => Fold m Char b -> Stream m Char -> Stream m b
1113−words = S.wordsBy isSpace
1107+words f m = Stream.fromStreamD $ D.wordsBy isSpace f (Stream.toStreamD m)
1114
1108
1115-- | Unfold a stream to character streams using the supplied 'Unfold'
1109-- | Unfold a stream to character streams using the supplied 'Unfold'
1116-- and concat the results suffixing a newline character @\\n@ to each stream.
1110-- and concat the results suffixing a newline character @\\n@ to each stream.
@@ -1122,8 +1116,8 @@ words = S.wordsBy isSpace
1122--
1116--
1123-- /Pre-release/
1117-- /Pre-release/
1124{-# INLINE unlines #-}
1118{-# INLINE unlines #-}
1125−unlines :: (MonadIO m, IsStream t) => Unfold m a Char -> t m a -> t m Char
1119+unlines :: (MonadIO m) => Unfold m a Char -> Stream m a -> Stream m Char
1126−unlines = S.interposeSuffix '\n'
1120+unlines = Stream.interposeSuffix '\n'
1127
1121
1128-- | Unfold the elements of a stream to character streams using the supplied
1122-- | Unfold the elements of a stream to character streams using the supplied
1129-- 'Unfold' and concat the results with a whitespace character infixed between
1123-- 'Unfold' and concat the results with a whitespace character infixed between
@@ -1136,5 +1130,5 @@ unlines = S.interposeSuffix '\n'
1136--
1130--
1137-- /Pre-release/
1131-- /Pre-release/
1138{-# INLINE unwords #-}
1132{-# INLINE unwords #-}
1139−unwords :: (MonadIO m, IsStream t) => Unfold m a Char -> t m a -> t m Char
1133+unwords :: (MonadIO m) => Unfold m a Char -> Stream m a -> Stream m Char
1140−unwords = S.interpose ' '
1134+unwords = Stream.interpose ' '
src/Streamly/Internal/Unicode/String.hs → core/src/Streamly/Internal/Unicode/String.hsrenamed+1−1
@@ -44,7 +44,7 @@ import Language.Haskell.TH.Quote
44import qualified Streamly.Data.Fold as Fold
44import qualified Streamly.Data.Fold as Fold
45import qualified Streamly.Internal.Data.Parser as Parser
45import qualified Streamly.Internal.Data.Parser as Parser
46 (some, many, takeWhile1)
46 (some, many, takeWhile1)
47−import qualified Streamly.Internal.Data.Stream.IsStream as Stream
47+import qualified Streamly.Data.Stream as Stream (fromList, parse)
48import qualified Streamly.Internal.Unicode.Char.Parser as Parser
48import qualified Streamly.Internal.Unicode.Char.Parser as Parser
49
49
50-- $setup
50-- $setup
src/Streamly/Unicode/Stream.hs → core/src/Streamly/Unicode/Stream.hsrenamed

The content is the same.

core/streamly-core.cabal+10
@@ -326,6 +326,12 @@ library
326 , Streamly.Internal.Data.Array.Stream.Fold.Foreign
326 , Streamly.Internal.Data.Array.Stream.Fold.Foreign
327
327
328 , Streamly.Internal.Data.Array.Stream.Foreign
328 , Streamly.Internal.Data.Array.Stream.Foreign
329+
330+ -- streamly-unicode
331+ , Streamly.Internal.Unicode.Stream
332+ , Streamly.Internal.Unicode.String
333+ , Streamly.Internal.Unicode.Char.Parser
334+ , Streamly.Internal.Unicode.Array.Char
329
335
330 -- Ring Arrays
336 -- Ring Arrays
331 , Streamly.Internal.Data.Ring.Foreign
337 , Streamly.Internal.Data.Ring.Foreign
@@ -344,6 +350,9 @@ library
344 , Streamly.Data.Array.Unboxed
350 , Streamly.Data.Array.Unboxed
345 , Streamly.Data.Array.Unboxed.Mut
351 , Streamly.Data.Array.Unboxed.Mut
346
352
353+ -- Text Processing
354+ , Streamly.Unicode.Stream
355+
347 if flag(dev)
356 if flag(dev)
348 exposed-modules:
357 exposed-modules:
349 Streamly.Internal.Data.Stream.StreamDK
358 Streamly.Internal.Data.Stream.StreamDK
@@ -363,6 +372,7 @@ library
363 , ghc-prim >= 0.2 && < 0.10
372 , ghc-prim >= 0.2 && < 0.10
364 , mtl >= 2.2 && < 2.3
373 , mtl >= 2.2 && < 2.3
365 , transformers >= 0.4 && < 0.7
374 , transformers >= 0.4 && < 0.7
375+ , template-haskell >= 2.13 && < 2.20
366
376
367 , fusion-plugin-types >= 0.1 && < 0.2
377 , fusion-plugin-types >= 0.1 && < 0.2
368
378
streamly.cabal+5−9
@@ -221,6 +221,11 @@ extra-source-files:
221 core/src/Streamly/Data/Array/Unboxed/Mut.hs
221 core/src/Streamly/Data/Array/Unboxed/Mut.hs
222 core/src/Streamly/Internal/Data/Time/Clock/Darwin.c
222 core/src/Streamly/Internal/Data/Time/Clock/Darwin.c
223 core/src/Streamly/Internal/Data/Time/Clock/Windows.c
223 core/src/Streamly/Internal/Data/Time/Clock/Windows.c
224+ core/src/Streamly/Internal/Unicode/Array/Char.hs
225+ core/src/Streamly/Internal/Unicode/Char/Parser.hs
226+ core/src/Streamly/Internal/Unicode/Stream.hs
227+ core/src/Streamly/Internal/Unicode/String.hs
228+ core/src/Streamly/Unicode/Stream.hs
224 core/streamly-core.cabal
229 core/streamly-core.cabal
225 core/jsbits/clock.js
230 core/jsbits/clock.js
226 core/Setup.hs
231 core/Setup.hs
@@ -482,12 +487,8 @@ library
482 , Streamly.Internal.Data.Binary.Decode
487 , Streamly.Internal.Data.Binary.Decode
483
488
484 -- streamly-unicode
489 -- streamly-unicode
485− , Streamly.Internal.Unicode.Stream
486− , Streamly.Internal.Unicode.String
487 , Streamly.Internal.Unicode.Utf8
490 , Streamly.Internal.Unicode.Utf8
488 , Streamly.Internal.Unicode.Char
491 , Streamly.Internal.Unicode.Char
489− , Streamly.Internal.Unicode.Char.Parser
490− , Streamly.Internal.Unicode.Array.Char
491
492
492 -- streamly-filesystem
493 -- streamly-filesystem
493 , Streamly.Internal.FileSystem.Handle
494 , Streamly.Internal.FileSystem.Handle
@@ -504,9 +505,6 @@ library
504 -- Exposed modules
505 -- Exposed modules
505 , Streamly.Prelude
506 , Streamly.Prelude
506
507
507− -- Text Processing
508− , Streamly.Unicode.Stream
509−
510 -- Filesystem/IO
508 -- Filesystem/IO
511 , Streamly.FileSystem.Handle
509 , Streamly.FileSystem.Handle
512 , Streamly.Console.Stdio
510 , Streamly.Console.Stdio
@@ -573,13 +571,11 @@ library
573 , ghc-prim >= 0.2 && < 0.10
571 , ghc-prim >= 0.2 && < 0.10
574 , mtl >= 2.2 && < 2.4
572 , mtl >= 2.2 && < 2.4
575 , transformers >= 0.4 && < 0.7
573 , transformers >= 0.4 && < 0.7
576− , template-haskell >= 2.13 && < 2.20
577
574
578 , monad-control
575 , monad-control
579
576
580 -- The core streamly package
577 -- The core streamly package
581 , streamly-core == 0.1.0
578 , streamly-core == 0.1.0
582− , fusion-plugin-types >= 0.1 && < 0.2
583
579
584 , hashable >= 1.3 && < 1.5
580 , hashable >= 1.3 && < 1.5
585 , unordered-containers >= 0.2 && < 0.3
581 , unordered-containers >= 0.2 && < 0.3