Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
johannes-riecken opened this issue Jan 22, 2022 · 0 comments

Comments

@johannes-riecken
Copy link

johannes-riecken commented Jan 22, 2022

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"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant