on master help sign in
Make minor change to array module docs
commitba0d42aec0dffda628a4872063f63d90e6ccb1ad authorHarendra Kumar <harendra@composewell.com> dateMon 6 Mar 2023, 13:28 (4 years ago) parent65c86d6
3 files changed+18−7
core/src/Streamly/Data/Array.hs+10−4 core/src/Streamly/Data/MutArray.hs+5−2 core/src/Streamly/Data/MutArray/Generic.hs+3−1
core/src/Streamly/Data/Array.hs+10−4
@@ -9,7 +9,13 @@
99--
1010-- This module provides APIs to create and use unboxed immutable arrays. Once
1111-- created, their contents cannot be modified. Only types that are unboxable
12−-- via the 'Unbox' type class can be stored in these arrays.
12+-- via the 'Unbox' type class can be stored in these arrays. Note that the
13+-- array memory grows automatically when creating a new array, therefore, an
14+-- array can be created from a variable length stream.
15+--
16+-- See "Streamly.Data.Array.Generic" for arrays that work for boxed types i.e.
17+-- not requiring the 'Unbox' constraint.
18+-- See "Streamly.Data.MutArray" for arrays that can be mutated in-place..
1319--
1420-- = Folding Arrays
1521--
@@ -55,6 +61,9 @@
5561-- >>> Stream.fold (purely Array.write) $ Stream.fromList [1,2,3::Int]
5662-- Identity fromList [1,2,3]
5763--
64+-- Since it is a pure stream we can use 'unsafePerformIO' to extract the result
65+-- of fold from IO.
66+--
5867-- Alternatively, 'Identity' streams can be generalized to IO streams:
5968--
6069-- >>> pure = Stream.fromList [1,2,3] :: Stream Identity Int
@@ -62,9 +71,6 @@
6271-- >>> Stream.fold Array.write (generally pure :: Stream IO Int)
6372-- fromList [1,2,3]
6473--
65−-- Since it is a pure stream we can use 'unsafePerformIO' to extract the result
66−-- of fold from IO.
67−--
6874-- = Programming Tips
6975--
7076-- This module is designed to be imported qualified:
core/src/Streamly/Data/MutArray.hs+5−2
@@ -7,9 +7,12 @@
77-- Stability : released
88-- Portability : GHC
99--
10−-- This module provides mutable arrays suitable for long lived data storage,
11−-- random access, and mutation.
10+-- Mutable version of "Streamly.Data.Array". Please refer to that module for
11+-- general documentation. The contents of mutable ararys can be modified
12+-- in-place.
1213--
14+-- See "Streamly.Data.MutArray.Generic" for mutable arrays that work for boxed
15+-- types i.e. not requiring the 'Unbox' constraint.
1316
1417module Streamly.Data.MutArray
1518 (
core/src/Streamly/Data/MutArray/Generic.hs+3−1
@@ -6,7 +6,9 @@
66-- Stability : experimental
77-- Portability : GHC
88--
9−-- Mutable variant of the "Streamly.Data.Array.Generic" module.
9+-- Unconstrained version of "Streamly.Data.MutArray" module.
10+--
11+-- See the "Streamly.Data.MutArray" module for documentation.
1012--
1113module Streamly.Data.MutArray.Generic
1214(