Pierre-Etienne Meunier wrote:
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
On May 9, 2010, at 07:18 , wren ng thornton wrote:
Where available, the fmap version is the most efficient. The liftM
function can be less efficient since it's defined generically
(namely with the bind/return definition above), whereas fmap can
take advantage of knowing the specific monad
Almost - liftM modificationTime has type Status - IO EpochTime. Like
other IO functions (getLine, putStrLn), it returns an IO action but accepts
a pure value (the modification time)
Also, I like this style:
import Control.Applicative (($))
blah = do
times - mapM (PF.modificationTime $
Bill Atkins wrote:
Almost - liftM modificationTime has type Status - IO EpochTime.
Like other IO functions (getLine, putStrLn), it returns an IO action
but accepts a pure value (the modification time)
Also, I like this style:
import Control.Applicative (($))
blah = do
times - mapM
On Thu, May 6, 2010 at 11:51 AM, Bill Atkins watk...@alum.rpi.edu wrote:
Almost - liftM modificationTime has type Status - IO EpochTime. Like
other IO functions (getLine, putStrLn), it returns an IO action but accepts
a pure value (the modification time)
ghci :m +Control.Monad
Yep, you and Ben are both correct. Mea culpa and sorry for the bad answer.
Just curious: why does getModificationTime take an IO FileStatus rather than
a FileStatus?
On Thu, May 6, 2010 at 7:00 AM, Neil Brown nc...@kent.ac.uk wrote:
Bill Atkins wrote:
Almost - liftM modificationTime has
On Thu, May 6, 2010 at 12:37 PM, Bill Atkins watk...@alum.rpi.edu wrote:
Just curious: why does getModificationTime take an IO FileStatus rather than
a FileStatus?
It doesn't. getModificationTime is a pure function (think of it like a
record accessor).
liftM makes it take IO FileStatus
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
Pierre-Etienne Meunier pierreetienne.meun...@gmail.com writes:
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
On Thu, 06 May 2010 12:00:01 +0100
Neil Brown nc...@kent.ac.uk wrote:
At which point I prefer Ivan's liftM version rather than the above
section (or worse: using ($) prefix). The original request is a
relatively common thing to want to do, so I was slightly surprised
that hoogling for:
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.
On 6 May 2010 15:01, bri...@aracnet.com wrote:
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)
times - mapM (liftM PF.modificationTime .
On Thu, 6 May 2010 15:07:30 +1000
Ivan Miljenovic ivan.miljeno...@gmail.com wrote:
On 6 May 2010 15:01, bri...@aracnet.com wrote:
I was doing the following:
do status - mapM PF.getFileStatus filenames
let times = map PF.modificationTime status
let sorted = sortBy (\(_, t1)
On 6 May 2010 15:20, bri...@aracnet.com wrote:
well now it's obvious :-) I did have liftM in there, but just couldn't
quite figure out how to tie things together.
to be completely clear : liftM takes modificationTime from
Status - EpochTime
to
IO Status - IO EpochTime
You can see it
14 matches
Mail list logo