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

Chris Kuklewicz haskell at list.mightyreason.com
Mon Dec 19 17:22:19 EST 2005


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)

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

Andrew Pimlott wrote:
> On Mon, Dec 19, 2005 at 01:42:19PM -0600, Steve Harris wrote:
> 
>>What I'm after is something like:
>> -- (psuedo-code)
>> [(b,c,d) |
>>           b <- getDirectoryContents a_dir,
>>           c <- getDirectoryContents (a_dir ++ "/" ++ b),
>>           d <- getDirectoryContents (a_dir ++ "/" ++ b ++ "/" ++ c) ],
> 
> 
> Check out Control.Monad.List.ListT, which combines list non-determinism
> with another monad.  Eg,
> 
>     ListT (getDirectoryContents a_dir) :: ListT IO FilePath
> 
> Andrew
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 



More information about the Haskell-Cafe mailing list