July 2023
Intermediate to advanced
670 pages
17h 13m
English
Imagine that we wanted to create a type class that represents things that can be “empty” for some definition of empty that will depend on the particular type. In this exercise, we’ll call the type class Nullable and give it two functions:
| | module Nullable where |
| | import Prelude hiding (null) |
| | |
| | class Nullable a where |
| | isNull :: a -> Bool |
| | null :: a |
Create instances of this type class for:
Add a new Eq constraint to the definition of Nullable:
| | class Eq a => Nullable |