on master help sign in
Add skeletons for fromListRev and fromListRevN
commit16e751cc0999f79ab32e5d8dc394c144a2b4ee66 authorHarendra Kumar <harendra@composewell.com> dateMon 26 Apr 2021, 19:38 (5 years ago) parent15209b3
1 file changed+24
src/Streamly/Internal/Data/Array/Foreign/Type.hs+24
src/Streamly/Internal/Data/Array/Foreign/Type.hs+24
@@ -29,6 +29,8 @@ module Streamly.Internal.Data.Array.Foreign.Type
2929 , fromCString#
3030 , fromList
3131 , fromListN
32+ , fromListRev
33+ , fromListRevN
3234 , fromStreamDN
3335 , fromStreamD
3436
@@ -295,6 +297,20 @@ fromCString# addr# = do
295297fromListN :: Storable a => Int -> [a] -> Array a
296298fromListN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListN n xs
297299
300+-- XXX We can possibly have a direction flag in the array to reverse it without
301+-- actually doing anything. With that we can just do "reverse . fromList". But
302+-- it may complicate all the APIs as all reads of the array will have to handle
303+-- the flag.
304+--
305+-- | Create an 'Array' from the first N elements of a list in reverse order.
306+-- The array is allocated to size N, if the list terminates before N elements
307+-- then the array may hold less than N elements.
308+--
309+-- /Unimplemented/
310+{-# INLINABLE fromListRevN #-}
311+fromListRevN :: {- Storable a => -} Int -> [a] -> Array a
312+fromListRevN _n _xs = undefined
313+
298314-- | Create an 'Array' from a list. The list must be of finite size.
299315--
300316-- /Since 0.7.0 (Streamly.Memory.Array)/
@@ -304,6 +320,14 @@ fromListN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListN n xs
304320fromList :: Storable a => [a] -> Array a
305321fromList xs = unsafePerformIO $ unsafeFreeze <$> MA.fromList xs
306322
323+-- | Create an 'Array' from a list in reverse order. The list must be of finite
324+-- size.
325+--
326+-- /Unimplemented/
327+{-# INLINABLE fromListRev #-}
328+fromListRev :: {- Storable a => -} [a] -> Array a
329+fromListRev _xs = undefined
330+
307331{-# INLINE_NORMAL fromStreamDN #-}
308332fromStreamDN :: forall m a. (MonadIO m, Storable a)
309333 => Int -> D.Stream m a -> m (Array a)