[Haskell] return?

Ben_Yu at asc.aon.com Ben_Yu at asc.aon.com
Thu Apr 29 19:27:32 EDT 2004





Hi,
While writing monad programs, I sometimes want to do a return as it is in
imperative program. i.e.,
do{return 1; return 2} is same as return 1

This seems useful to me when I need to do something like
do
  mwhen cond $ return 1
  ...... -- subsequent actions


I know I can do
if cond then return 1 else (
  ...--subsequent actions
  )


 However, that syntax does not look very pleasant to me due to this extra
indentation and the pair of parens.


Is this possible at all?

Ben.



More information about the Haskell mailing list