if first.isJust then first else second c && (!a || !b) == c && !(a && b)
false (all lower case) are the values of type
if expressions have the following form:
if expression then expression else expression
The condition must be of type
There is no implicit conversion to
Boolean from, for example,
The types of the
else branches must be the same.
if must have an
else branch, there is no
else branch will extend as far as possible.
Example: To clarify by what “as far as possible” means, the following code:
if condition then foo else bar ++ if condition2 then foo2 else bar2 ++ more
will parse as
if (condition) then (foo) else (bar ++ if (condition2) then (foo2) else (bar2 ++ more))
The standard C-style boolean operators are present:
expression && expression expression || expression !expression
These operators DO short-circuit evaluation.
Again, the operands must be of type
Boolean, there are no implicit conversions.
The not operator binds more tightly than the and operator, which binds more tightly than the or operator, as you would expect.
All comparison operators bind more tightly than logical operators and produce
The following comparison operators work on types
expression < expression expression <= expression expression > expression expression >= expression expression == expression expression != expression
String comparison is lexicographical, and does pay attention to case.
Equality and inequality will also work with
Booleans, but the other comparison operators will not.