[Haskell-beginners] Early return in IO monad

Tidus Zero gnusokyo at gmail.com
Sat Aug 31 22:03:35 CEST 2013


You can use the EitherT monad with IO and use the 'left' function  
which is just 'fail' to return early if you aren't restricted to only  
use the IO monad.

Sent from my iGNU

On 31. aug. 2013, at 20.05, Nathan Hüsken <nathan.huesken at posteo.de>  
wrote:

> Hey,
>
> Is it somehow possible to return "early" in a do block of the IO  
> monad?
> The eqivalent do in C:
>
> void doBlock() {
>    if (some preCondition) {
>      return;
>    }
>    ...
> }
>
> ???
>
> Thanks!
> Nathan
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list