CK Kashyap <ck_kash...@yahoo.com> writes:
> 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.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to