July 2023
Intermediate to advanced
670 pages
17h 13m
English
Consider a function that takes three integers but hasn’t been defined:
| | addThree :: Int -> Int -> Int -> Int |
There are several different ways that you could write a function like this. For example, here are two possible definitions:
| | -- definition 1 |
| | addThree = undefined |
| | |
| | -- definition 2 |
| | addThree a b c = undefined |
There are many other ways we could use undefined to write a version of addThree that type checks. Why are there so many different versions?
The behavior of the following functions from base can be easily predicted based on their type. Review the type of each of these functions and try to guess at how they are implemented. Use ghci to see if you were right. Are ...
Read now
Unlock full access