Skip to content

Commit

Permalink
Make fromPtrN monadic
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Oct 6, 2024
1 parent 43f73e7 commit 40cbd64
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core/src/Streamly/Internal/Data/Array/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,6 @@ fromPureStream x = unsafePerformIO $ fmap unsafeFreeze (MA.fromPureStream x)
-- fromPureStream = runIdentity . D.fold (unsafeMakePure write)
-- fromPureStream = fromList . runIdentity . D.toList

-- XXX This should be monadic.

-- | @fromPtrN len addr@ copies @len@ bytes from @addr@ into an array. The
-- memory pointed by @addr@ must be pinned or static.
--
Expand All @@ -953,8 +951,8 @@ fromPureStream x = unsafePerformIO $ fmap unsafeFreeze (MA.fromPureStream x)
--
-- Note that this should be evaluated strictly to ensure that we do not hold
-- the reference to the pointer in a lazy thunk.
fromPtrN :: Int -> Ptr Word8 -> Array Word8
fromPtrN n addr = unsafePerformIO $ fmap unsafeFreeze (MA.fromPtrN n addr)
fromPtrN :: MonadIO m => Int -> Ptr Word8 -> m (Array Word8)
fromPtrN n addr = fmap unsafeFreeze (MA.fromPtrN n addr)

-- | Copy a null terminated immutable 'Addr#' Word8 sequence into an array.
--
Expand Down

0 comments on commit 40cbd64

Please sign in to comment.