[Haskell-cafe] comprehension generators from IO [a]'s ?

Steve Harris steveofar at gmail.com
Mon Dec 19 18:13:01 EST 2005


On 12/19/05, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> Okay...that works.  Sweet.
>
> gdc x = ListT $ getDirectoryContents x
>
> get3levels top = runListT $ do
>   b <- gdc top
>   c <- gdc $ top++('/':b)
>   d <- gdc $ top++('/':b)++('/':c)
>   return (b,c,d)

Yeah, that's awesome: just as readable as the comprehension
psuedo-code if not more-so.  I knew some monad wizards would step out
with something nice.

Thanks for spelling out what Andrew was getting at also, it would have
been lost on me.  I haven't yet ventured into using any monads but IO
yet, maybe ListT would be a good place to start.


> I feel bound to point out http://haskell.org/hawiki/ListTDoneRight which
> has more to say about the details of ListT

OK. Thanks to you both Chris and Andrew.

Steve


More information about the Haskell-Cafe mailing list