Introduction
Introduction
A type class defines some types related by their operations. This is saying that typeclasses are usually defined in terms of those operations, and these operations group those type together.
For example, we can put all types that can be converted to a String in the same type class called Show .
We can introduce this Show type class by:
class Show a where
show :: a -> String
Then we can give an instance to the type class.
instance Show String where
show s = s
instance Show Boolean where
show true = "true"
show false = "false"
