parsec
parsec copied to clipboard
Which unfoldM is meant in "unfoldM uncons gives the [t] corresponding to the stream"?
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"?