This document discusses Haskell concepts and how they compare to object-oriented programming concepts in languages like C++ and Python. It covers topics like algebraic data types, classes and instances in Haskell, and how concepts like private fields differ between Haskell and other languages. It also includes examples of data types, functions, and classes in Haskell as well as frequently asked questions about Haskell features.
50. class instance
class instance
Eq
class Eq a where
(==), (/=) :: a -> a -> Bool
MyType
instance Eq MyType where
x == y = ...
-- (==) :: MyType -> MyType -> Bool
51. class
Eq
class (Eq a) => Ord a where
(<=) :: a -> a -> Bool Ord
...
52. class
class (Eq a, Show a) => Num a where
(+) :: a -> a -> a
...
Show Eq
Num
53. Read
Show
instance
Typeable
Bounded Ix
Enum Data
Ord Eq
instance
MyType
54. deriving
data deriving
data MyType a b c = A a | B b | C c
deriving (Eq, Ord, Show, Read)
Read
Show
Ord Eq
MyType