[Haskell-cafe] Conditionals and case expressions in do blocks

Edward Z. Yang ezyang at MIT.EDU
Wed Jan 26 22:02:55 CET 2011


Excerpts from Edward Amsden's message of Wed Jan 26 15:51:46 -0500 2011:
> do
> ...
> case ... of
> Foo x -> do ...
>                   ...
>                   return foobar
> Bar x -> do ...
>                  ...
>                  return foobar

There's not enough context here to say what is appropriate.
Is foobar defined in the outer or inner do-block?

> if cond
>   then throwError "BBQ!"
>   else do
>          ...
>          ...
>          return ...

Try:

    when cond $ throwError "BBQ!"
    ...
    ...
    return ...

Cheers,
Edward



More information about the Haskell-Cafe mailing list