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
That"s a great question but unfortunately there is a key difference between Effect/Option and Array/Stream/Chunk the former are one-shot as in they emit a single value, the latter are multi-shot as in they emit multiple values. Mutable delimited continuations (generators) are only valid to express one-shot effect types, to be able to implement it for multi-shot we would either need an Immutable delimited continuation (not available in JS) or need to replay the generator from scratch (duplicating side effects and introducing a performance bottleneck). For this reason we decided not to implement it.
What is the problem this feature would solve?
Since
effect
already supportOption.gen
andEither.gen
, why not supportArray.gen
?What is the feature you are proposing to solve the problem?
When working with
Option
, you can:The same applies to
Either
. SinceArray
also implements theMonad
interface, why not:This
Array.gen
would work the same way asArray.Do
with the syntactic conveniences of the generator approach.syntactic
What alternatives have you considered?
The
cartesianProduct
example could also be implemented withArray.Do
:Still, I find
Array.gen
and/orChunk.gen
a good addition to the library.The text was updated successfully, but these errors were encountered: