haskell / haskell/parsec

Which unfoldM is meant in "unfoldM uncons gives the [t] corresponding to the stream"?

Open
#144 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
892
Forks
99
PR merge metrics
No merged PRs in 30d

Description

The documentation for Stream mentions "unfoldM uncons gives the [t] corresponding to the stream", but unfoldM doesn't exist in base or parsec package. I assume the monadification of Data.List's unfoldr is meant if evaluated in the identity monad? Then maybe this would be a better documentation:

```
unfoldM uncons gives the [t] corresponding to the stream if the result type is the Identity monad and unfoldM is defined as follows:
unfoldM :: Monad m => (a -> m (Maybe (b, a))) -> a -> m [b]
unfoldM f b = do
fb <- f b
case fb of
Just (a, b') -> pure ((:) a) <*> unfoldM f b'
Nothing -> pure []
```

Or maybe change it to "`unfoldr (runIdentity . uncons)` gives the [t] corresponding to the stream"?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.