on master help sign in
Add some notes in the immutable array module
commita9f0d38136a8f0cd2efed2742d104c74b28e3c40 authorAdithya Kumar <adithya@composewell.com> dateWed 19 Jul 2023, 20:32 (3 years ago) parentaa02380
1 file changed+18
core/src/Streamly/Internal/Data/Array/Type.hs+18
core/src/Streamly/Internal/Data/Array/Type.hs+18
@@ -110,6 +110,24 @@ import Streamly.Internal.System.IO (unsafeInlineIO, defaultChunkSize)
110110
111111#include "DocTestDataArray.hs"
112112
113+-------------------------------------------------------------------------------
114+-- Notes
115+-------------------------------------------------------------------------------
116+
117+-- IMPORTANT:
118+
119+-- We need to be careful while using unsafePerformIO when array creation is
120+-- involved.
121+--
122+-- * We need to make sure the unsafe IO line does not float out of the binding.
123+-- * The order of the IO actions should be sane. For example, `touch` after `f`.
124+--
125+-- Assume the unsafe IO action floats up. If it makes sense given this
126+-- assumption, it's probably OK to use usafe IO.
127+--
128+-- A general approach should be never to use unsafe IO where Array creation is
129+-- involved or touch is involved.
130+
113131-------------------------------------------------------------------------------
114132-- Array Data Type
115133-------------------------------------------------------------------------------