First page Back Continue Last page Summary Graphics
Type classes (mix-ins)
Type class = special kind of module
- some functions are virtual
- specify the type of those functions (for static typing)
- 1 ensure a common behaviour
- write other functions using those virtual functions
Example:
- class Eq(a) where
- == :: a,a -> bool
- x!=y = ! (x==y)
- (this type is parametric, more about it in next slide)
Notes: