
29 Dec
2009
29 Dec
'09
7:11 a.m.
CK Kashyap
What are the benefits of making it an instance of Functor?
The ability to use fmap rather than liftM.
I'd appreciate it very much if you could give me some pointers on the usages of guard, when and msum.
You can use when to have an operation occur only when a condition is true: when :: (Monad m) => Bool -> m () -> m () e.g. to delete a file only if it actually exists: ,---- | tryDeleteFile :: FilePath -> IO () | tryDeleteFile f = do ex <- doesFileExist f | when ex (removeFile f) `---- -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com