[Haskell] return?

John Meacham john at repetae.net
Fri Apr 30 03:27:42 EDT 2004

On Thu, Apr 29, 2004 at 06:27:32PM -0500, Ben_Yu at asc.aon.com wrote:
> 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
> 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.

you can make things somewhat better with this construct

foo = do
        if cond then return bar else do
the lack of an early return seems like an ommision from the do syntax,
but an understandable one.

John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Haskell mailing list