Skip to content

Commit

Permalink
Support streamly-core-0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Nov 29, 2024
1 parent 1417dc4 commit 58bff93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Streamly/External/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ pinnedCreate = Array.pinnedWrite
ensurePinned = pure
pinnedCreateOf = Array.writeN
pinnedCreate = Array.write
array_createN = Array.writeN

Check failure on line 104 in src/Streamly/External/ByteString.hs

View workflow job for this annotation

GitHub Actions / 9.2.7+streamly-core-0.1.0

• Ambiguous type variable ‘m0’ arising from a use of ‘Array.writeN’
#endif

#if MIN_VERSION_streamly_core(0,3,0)
#define CREATE_N Array.createOf
#else
#define CREATE_N Array.writeN
#endif

{-# INLINE mutableByteArrayContents# #-}
Expand Down Expand Up @@ -129,7 +136,7 @@ toArray (CONSTRUCTOR((ForeignPtr addr# (PlainPtr marr#)), off0, len)) =
toArray (CONSTRUCTOR(fptr, off, len)) =
unsafeInlineIO
$ withForeignPtr (fptr WHEN_0_10_12(`plusForeignPtr` off))
$ Unfold.fold (Array.writeN len) generator
$ Unfold.fold (CREATE_N len) generator

where

Expand Down
8 changes: 7 additions & 1 deletion src/Streamly/External/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ import qualified Streamly.Data.Stream as Stream

import Prelude hiding (read)

#if MIN_VERSION_streamly_core(0,3,0)
#define UNFOLD_EACH Unfold.unfoldEach
#else
#define UNFOLD_EACH Unfold.many
#endif

-- | Unfold a lazy ByteString to a stream of 'Array' 'Words'.
{-# INLINE chunkReader #-}
chunkReader :: Monad m => Unfold m ByteString (Array Word8)
Expand All @@ -49,7 +55,7 @@ chunkReader = Unfold step seed
-- | Unfold a lazy ByteString to a stream of Word8
{-# INLINE reader #-}
reader :: Monad m => Unfold m ByteString Word8
reader = Unfold.many Array.reader readChunks
reader = UNFOLD_EACH Array.reader readChunks

-- TODO: "toChunks" should be called "read" instead
-- | Convert a lazy 'ByteString' to a serial stream of 'Array' 'Word8'.
Expand Down
2 changes: 1 addition & 1 deletion streamly-bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library
|| == 0.11.4.*
|| == 0.11.5.*
|| == 0.12.0.*
, streamly-core >= 0.1.0 && < 0.2.3
, streamly-core >= 0.1.0 && < 0.3.1
default-language: Haskell2010

test-suite sb-test
Expand Down

0 comments on commit 58bff93

Please sign in to comment.