| Start |
|---|
| Eq All basic datatypes (like Required methods
Defines
Direct superclassesNone Notable subclasses |
| Ord Types instantiating
Required methods
Defines
Direct superclasses |
| Monoid Types instantiating Intuitively, Required methods
Direct superclassesNone |
| Num The most general class for number types, more precisely for rings (opens new window), 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 ( Note that the rules for the numerical classes are much less strictly obeyed than the monad (opens new window) or monoid laws, or those for equality comparison (opens new window). In particular, floating-point numbers generally obey laws only in a approximate sense. The methodsfor the most common instances, multiplication is also commutative, but this is definitely not a requirement. negate :: Num a => a -> a. The full name of the unary negation operator. -1 is syntactic sugar for negate 1.
signum :: Num a => a -> a. The sign function, according to the name, yields only -1 or 1, depending on the sign of the argument. Actually, that's only true for nonzero real numbers; in general signum is better understood as the normalising function: Note that section 6.4.4 of the Haskell 2010 Report (opens new window) explicitly requires this last equality to hold for any valid Some libraries, notably linear (opens new window) and hmatrix (opens new window), have a much laxer understanding of what the † In particular, the “negatives” of unsigned types are wrapped around to large positive, e.g. ‡ This is widely not fulfilled: vector types do not have a real subset. The controversial |
| Maybe and the Functor Class In Haskell, data types can have arguments just like functions. Take the
Its actual declaration is fairly simple. What this tells is that a This idea of wrapping types to give them additional functionality is a very useful one, and is applicable to more than just It is common to think of these kinds of types as boxes which can have values placed in them. Different boxes hold different values and do different things, but none are useful without being able to access the contents within. To encapsulate this idea, Haskell comes with a standard typeclass, named As can be seen, the class has a single function, In simple terms, |
| Type class inheritance: Ord type class Haskell supports a notion of class extension. For example, the class The All of the methods following Type classes that themselves extend RemarksThe following diagram taken from the Typeclassopedia (opens new window) article shows the relationship between the various typeclasses in Haskell. |
Read Article
https://develop.horje.com/learn/1434/reference