-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add evalListT to get results from ListT as a list #184
base: main
Are you sure you want to change the base?
Conversation
This implementation is wrong. Sorry. |
New commit fixes the implementation and it now works as expected. |
A simpler implementation is to define this in terms of evalListT :: Monad m => ListT m a -> m [a]
evalListT = Pipes.Prelude.toListM . Pipes.enumerate I would also suggest naming this something like |
I found myself wishing for this function, for the same reasons that I appreciate
I considered naming it It can indeed be defined very nicely as So then I started thinking about how this would fit into Having talked myself out of wanting this function, I'm now of the opinion that there are a handful of documentation opportunities here instead:
|
@chris-martin: If you put up a pull request, I'd accept it |
Lovely! I intend to. |
This implements several of the documentation ideas I brought up in Gabriella439#184. The present problem, I think, is that it is not obvious how to accomplish some basic ListT tasks (e.g. converting `ListT m a` to `m [a]`) unless you have the habit of knowing to convert to Producer first. I also wanted to emphasize some of the things that you can do using just the typeclass instances. I'm aiming to augment the ListT API documentation with just enough links and suggestions to serve as jumping-off points, without cluttering up the haddock page for the Pipes module too much.
This implements several of the documentation ideas I brought up in #184. The present problem, I think, is that it is not obvious how to accomplish some basic ListT tasks (e.g. converting `ListT m a` to `m [a]`) unless you have the habit of knowing to convert to Producer first. I also wanted to emphasize some of the things that you can do using just the typeclass instances. I'm aiming to augment the ListT API documentation with just enough links and suggestions to serve as jumping-off points, without cluttering up the haddock page for the Pipes module too much.
The proper way to use
ListT
in pipes is to have an underlying monad and effect per choice through that monad. However, sometimes it's really convenient to run aListT
computation and then get the results in the underlying monad as a list. Since the MTL'sListT
is more restrictive, many use cases for this functionality would be helped by using pipes'ListT
, while still obtaining the results as a list.