[Haskell-beginners] What is the Haskell idiom for "if then else if then"

Hrushikesh Tilak hrushikesh.tilak at gmail.com
Tue Mar 31 04:03:08 EDT 2009


http://www.haskell.org/haskellwiki/If-then-else#Replace_syntactic_sugar_by_a_function
mentions that there is no such function in Prelude.


On Mon, Mar 30, 2009 at 11:33 AM, Peter Hickman <peterhi at ntlworld.com> wrote:
>
> I've just written this piece of code
>
>    if r < 0
>    then LEFT
>    else
>        if r > 0
>        then RIGHT
>        else STRAIGHT
>
> which works just fine but it does look rather clunky (as it would in any language I suppose). Is there a Haskell idiom for this type of code?
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


More information about the Beginners mailing list