Skip to content

Commit

Permalink
stop exporting ArrayStream APIs from Array module
Browse files Browse the repository at this point in the history
This module is now only for convenience as all APIs can be expressed in terms
of Stream APIs with the same performance.
  • Loading branch information
harendra-kumar committed Sep 25, 2019
1 parent 8fbb4d4 commit b8b3e17
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
5 changes: 3 additions & 2 deletions examples/HandleIO.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import qualified Streamly.Prelude as S
import qualified Streamly.Data.Fold as FL
import qualified Streamly.Memory.Array as A
-- import qualified Streamly.Memory.Array as A
import qualified Streamly.Internal.Memory.ArrayStream as AS
import qualified Streamly.FileSystem.Handle as FH
import qualified System.IO as FH
-- import qualified Streamly.FileSystem.FD as FH
Expand All @@ -25,7 +26,7 @@ ord' = (fromIntegral . ord)

wcl :: FH.Handle -> IO ()
wcl src = print =<< (S.length
$ A.splitOn 10
$ AS.splitOn 10
$ FH.readArrays src)
{-
-- Char stream version
Expand Down
9 changes: 5 additions & 4 deletions src/Streamly/Benchmark/FileIO/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import qualified Streamly.Memory.Array as A
import qualified Streamly.Prelude as S
import qualified Streamly.Data.String as SS
import qualified Streamly.Internal.Prelude as Internal
import qualified Streamly.Internal.Memory.ArrayStream as AS

#ifdef INSPECTION
import Foreign.Storable (Storable)
Expand Down Expand Up @@ -81,7 +82,7 @@ inspect $ 'countBytes `hasNoType` ''Step
-- | Count the number of lines in a file.
{-# INLINE countLines #-}
countLines :: Handle -> IO Int
countLines = S.length . A.splitOnSuffix 10 . FH.readArrays
countLines = S.length . AS.splitOnSuffix 10 . FH.readArrays

#ifdef INSPECTION
inspect $ hasNoTypeClasses 'countLines
Expand All @@ -92,7 +93,7 @@ inspect $ 'countLines `hasNoType` ''Step
-- | Count the number of lines in a file.
{-# INLINE countWords #-}
countWords :: Handle -> IO Int
countWords = S.length . A.splitOn 32 . FH.readArrays
countWords = S.length . AS.splitOn 32 . FH.readArrays

#ifdef INSPECTION
inspect $ hasNoTypeClasses 'countWords
Expand Down Expand Up @@ -141,7 +142,7 @@ linesUnlinesCopy :: Handle -> Handle -> IO ()
linesUnlinesCopy inh outh =
S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
$ Internal.insertAfterEach (return $ A.fromList [10])
$ A.splitOnSuffix 10
$ AS.splitOnSuffix 10
$ FH.readArraysOf (1024*1024) inh

#ifdef INSPECTION
Expand All @@ -156,7 +157,7 @@ wordsUnwordsCopy inh outh =
S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
$ S.intersperse (A.fromList [32])
-- XXX use a word splitting combinator
$ A.splitOn 32
$ AS.splitOn 32
$ FH.readArraysOf (1024*1024) inh

#ifdef INSPECTION
Expand Down
15 changes: 0 additions & 15 deletions src/Streamly/Memory/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@ module Streamly.Memory.Array
-- , runStreamFold
, runFold
-}

-- * Streams of Arrays
-- -- ** Creation
-- , AS.arraysOf

-- -- ** Elimination
-- , AS.concat
-- , AS.concatRev
-- , AS.toArray

-- ** Transformation
, AS.splitOn
, AS.splitOnSuffix
-- , AS.compact -- compact
)
where

Expand All @@ -149,7 +135,6 @@ import Streamly.Streams.StreamK.Type (IsStream)
import Streamly.Internal.Data.Fold.Types (Fold(..))

import qualified Streamly.Internal.Memory.Array.Types as A
import qualified Streamly.Internal.Memory.ArrayStream as AS
import qualified Streamly.Streams.Prelude as P
import qualified Streamly.Streams.Serial as Serial
import qualified Streamly.Streams.StreamD as D
Expand Down
3 changes: 2 additions & 1 deletion test/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Test.QuickCheck.Monadic (run, monadicIO, assert)
import Test.Hspec as H

import qualified Streamly.Memory.Array as A
import qualified Streamly.Internal.Memory.ArrayStream as AS
import qualified Streamly.Prelude as S
import qualified Streamly.Data.String as SS

Expand Down Expand Up @@ -75,7 +76,7 @@ testLinesArray =
monadicIO $ do
xs <- S.toList
$ S.map A.toList
$ A.splitOnSuffix 10
$ AS.splitOnSuffix 10
$ S.yield (A.fromList list)
assert (xs == map (map (fromIntegral . ord))
(lines (map (chr . fromIntegral) list)))
Expand Down

0 comments on commit b8b3e17

Please sign in to comment.