[Haskell-cafe] mixing map and mapM ?
Pierre-Etienne Meunier
pierreetienne.meunier at gmail.com
Thu May 6 08:32:55 EDT 2010
This way :
do
times<-mapM PF.getFileStatus filenames >>= return.(map PF.modificationTime)
Or also :
do
times<-mapM (PF.getFileStatus >>= (return.(PF.modificationTime))) filenames
let sorted=...
I do not know exactly how ghc compiles the IO monad, but it seems to me that the latter would allocate a little less.
Cheers,
PE
El 06/05/2010, a las 01:01, <briand at aracnet.com> <briand at aracnet.com> escribió:
>
> I was doing the following:
>
>
> do status <- mapM PF.getFileStatus filenames
> let times = map PF.modificationTime status
> let sorted = sortBy (\(_, t1) (_,t2) -> compare t1 t2) (zip filenames times)
>
> and I thought, surely I can combine the status and times definitions into one line, only I can't.
>
> Hint ?
>
> Thanks,
>
> Brian
> _______________________________________________
> 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