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
Let's say I have an IO-based Stream. Is it ever a good idea to pass the same Stream value to two different functions? As opposed of passing it to a function that returns a new Stream, or to a function that eliminates the Stream and brings us back to the base monad.
If the answer is no, perhaps we should document it, because newcomers to the library might not be aware of the need to follow that discipline (linear types could make it a compile-time restriction, but we don't have them in Haskell yet).
Is there any counterexample to this?
The text was updated successfully, but these errors were encountered:
Certainly a pure stream can be reused, regardless of the monad it's embedded in. Aside from that, I think any valid uses in IO would be fairly brittle and better expressed in other ways. For "pure" monads like [] and Maybe, it's harder to say.
There's an argument for using linear types for streams here.
Despite the emphasis on effects, if pure streams were used in non-linear fashion, there would be little guarantees that the contents of the streams aren't retained in memory, defeating the purpose of "streaming".
Let's say I have an
IO
-basedStream
. Is it ever a good idea to pass the sameStream
value to two different functions? As opposed of passing it to a function that returns a newStream
, or to a function that eliminates theStream
and brings us back to the base monad.If the answer is no, perhaps we should document it, because newcomers to the library might not be aware of the need to follow that discipline (linear types could make it a compile-time restriction, but we don't have them in Haskell yet).
Is there any counterexample to this?
The text was updated successfully, but these errors were encountered: