Tutorial by Examples

In Haskell, data types can have arguments just like functions. Take the Maybe type for example. Maybe is a very useful type which allows us to represent the idea of failure, or the possiblity thereof. In other words, if there is a possibility that a computation will fail, we use the Maybe type ther...
Haskell supports a notion of class extension. For example, the class Ord inherits all of the operations in Eq, but in addition has a compare function that returns an Ordering between values. Ord may also contain the common order comparison operators, as well as a min method and a max method. The =&...

Eq

All basic datatypes (like Int, String, Eq a => [a]) from Prelude except for functions and IO have instances of Eq. If a type instantiates Eq it means that we know how to compare two values for value or structural equality. > 3 == 2 False > 3 == 3 True Required methods (==) :: Eq ...

Ord

Types instantiating Ord include, e.g., Int, String, and [a] (for types a where there's an Ord a instance). If a type instantiates Ord it means that we know a “natural” ordering of values of that type. Note, there are often many possible choices of the “natural” ordering of a type and Ord forces us t...
Types instantiating Monoid include lists, numbers, and functions with Monoid return values, among others. To instantiate Monoid a type must support an associative binary operation (mappend or (<>)) which combines its values, and have a special "zero" value (mempty) such that combini...

Num

The most general class for number types, more precisely for rings, i.e. numbers that can be added and subtracted and multiplied in the usual sense, but not necessarily divided. This class contains both integral types (Int, Integer, Word32 etc.) and fractional types (Double, Rational, also complex n...

Page 1 of 1