Type Classes Flashcards
1
Q
What is the benefit of a static type system?
A
Types are defined before compile time. Therefore, the program wont compile if there are type errors.
2
Q
Define a typeclass
A
A type class is a class that certain types are a part of. For example, integer would be a part of the Ord type class.
3
Q
What are the 5 main type classes?
A
Eq, Ord, Show, Read, Num
4
Q
What is a benefit of type classes in regard to polymorphism?
A
Type classes enable the implementation of polymorphism without overloading functions.
5
Q
What is a type constraint in Haskell?
A
A type constrain uses a type class to restrict the types of function arguments to types of only that type class.