Operator & Meaning Example Usage
Comments
-- Start of comment line -- calculating the area of any triangle
{- Start of short comment {-
-} End of short comment calculating the area of any triangle given
the two lengths and enclosed angle.
-}
Mathematical
+ Add operator (+) 5 2 or 5 + 2
- Subtract/negate operator (-) 5 2 or 5 – 2
* Multiply operator (*) 5 2 or 5 * 2
/ Division operator (/) 5 2 or 5 / 2
/ Substitution operator, as in e{f/x}
^, ^^, ** Raise-to-the-power operators ( ^ ) raises any number to a nonnegative integer
power e.g. 5 ^ 2
( ^^ ) raises a fractional number to any integer
power e.g. 5.3 ^ 2
( ** ) takes two floating-point arguments e.g. 5.3 ^
2.4
&& And operator True && False
|| Or operator (5>2) || (3 > 4)
NOTE: The following operators and lexical symbols will be illustrated as they are introduced so as to
avoid confusion
Comparison Function
Used the same way as in C, C++ and Java \ Lambda operator
< Less-than operator . Function composition operator
<= Less-than-or-equal operator . Name qualifier
== Equal operator | Guard and case specifier
/= Not-equal operator | Separator in list comprehension
>= Greater-than-or-equal operator | Alternative in data definition (enum type)
Page 1 of 2
> Greater-than operator
Sequencing List
; Definition separator ++ List concatenation operator
-> Function type-mapping operator. : Append-head operator (\cons")
-> Lambda definition operator !! Indexing operator
-> Separator in case construction .. Range-specifier for lists
= Type- or value-naming operator \\ List-difference operator
:: Type specification operator, \has type" <- List comprehension generator
=> Context inheritance from class <- Single assignment operator in do-constr.
() Empty value in IO () type
>> Monad sequencing operator
>>= Monad sequencing operator with value
passing
>@> Object composition operator (monads)
(..) Constructor for export operator (postfix)
Constructors Patterns
[ and ] List constructors, \," as separator _ Wildcard in pattern
( and ) Tuple constructors, \," as separator ~ Irrefutable pattern
Infix-to-prefix constructors ! Force evaluation (strictness flag)
` and ` Prefix-to-infix constructors @ “Read As” in pattern matching
' and ' Literal char constructors
" and " String constructors
Page 2 of 2