Add evalListT to get results from ListT as a list#184
Add evalListT to get results from ListT as a list#184eamsden wants to merge 2 commits intoGabriella439:mainfrom
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.enumerateI 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
ListTin pipes is to have an underlying monad and effect per choice through that monad. However, sometimes it's really convenient to run aListTcomputation and then get the results in the underlying monad as a list. Since the MTL'sListTis more restrictive, many use cases for this functionality would be helped by using pipes'ListT, while still obtaining the results as a list.