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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 5 main type classes?

A

Eq, Ord, Show, Read, Num

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a benefit of type classes in regard to polymorphism?

A

Type classes enable the implementation of polymorphism without overloading functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly