[Haskell-beginners] Early return in IO monad
Kim-Ee Yeoh
ky3 at atamo.com
Sun Sep 1 17:37:35 CEST 2013
On Sun, Sep 1, 2013 at 1:05 AM, Nathan Hüsken <nathan.huesken at posteo.de>wrote:
> The eqivalent do in C:
>
> void doBlock() {
> if (some preCondition) {
> return;
> }
> ...
> }
>
Brent and Tony have already given the closest Haskell equivalents.
For completeness, it's worth pointing out that the above C is equivalent to
void doBlock() {
if (some preCondition) {
return;
} else {
...
}
}
So you can write it similarly in Haskell using if/then/else.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130901/21c30037/attachment.htm>
More information about the Beginners
mailing list