You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
511 B
8 lines
511 B
7 years ago
|
# Exercises: Parametricity
|
||
|
1. As said this is impossible. A function which takes any type and returns that same type can't be anything else. As soon as you choose something else, you pose limitations on the type. E.g. `square x = x * x` requires that `x` can be applied to `(*)`, which means it has to be of type `Num` at least.\
|
||
|
2. The only possibilies are to return either the first or the second argument.
|
||
|
1. `fst' a1 a2 = a1`
|
||
|
2. `snd' a1 a2 = a2`
|
||
|
3. Here there is only one possiblity: `snd'' a b = b`.
|
||
|
|