You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in the latest documentation. Possible candidates beyond fmap:
scan*
update, insertAt, and anything else we might've missed with a similar type signature -> a .. -> (Seq a, *).
dynamic constructors e.g. from*, replicate*, iterateN. although the documentation says they are O(n), from a quick reading of the source code it seems this really means "only if someone actually evaluates the whole thing e.g. by printing it", since the lazy parts of the Deep structure stay lazy
The text was updated successfully, but these errors were encountered:
infinity0
changed the title
Make whole/part-container transforms such as fmap strict
Seq: make whole/part-container transforms such as fmap strict
Nov 6, 2022
By sheer luck, in many cases giving a undefined will crash the dynamic constructors, because the periphery of the data structure is forced in the data definition. However we can carefully hack around this luck like this:
The last would be expected to fail in a proper strict container, and it does with Vector:
ghci> import Data.Strict.Vector as V
ghci> V.length $ V.fromList uf
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
error, called at libraries/base/GHC/Err.hs:75:14 in base:GHC.Err
undefined, called at <interactive>:14:22 in interactive:Ghci7
insertAt might be strict-safe by sheer virtue of having to reconstruct one half of the data structure (it crashed for me with undefined, for all params I thought to test), but it's hard to be sure if this holds for all possible parameters; safest to just stick a ! on the param anyway
As described in the latest documentation. Possible candidates beyond
fmap
:update
,insertAt
, and anything else we might've missed with a similar type signature-> a .. -> (Seq a, *)
.from*
,replicate*
,iterateN
. although the documentation says they are O(n), from a quick reading of the source code it seems this really means "only if someone actually evaluates the whole thing e.g. by printing it", since the lazy parts of the Deep structure stay lazySome technical details in haskell/containers#752
The text was updated successfully, but these errors were encountered: