index

8 Recursion

By the way, the Borges quote at the start of this chapter is only an example of recursion if the cartographer making the perfect map of England is himself in England. If instead, the cartographer is in Argentina (but not, perhaps Las Islas Malvinas) we don’t have self-reference, just reference.

8.1 Recursion

Intermission: Exercise

applyTimes 5 (+1) 5

turns into

((+1) . (+1) . (+1) . (+1) . (+1)) 5

8.3 Bottom

The bottom value in Haskell is what you get when you try to compute something that doesn’t compute. It’s a crash, an exception, an infinite loop and a fly in the ointment. We can’t totally get rid of the possibility of bottom in our code without sacrificing a lot of useful expressive power (because of the halting problem).

Bottom is a reminder that we don’t actually right code in the Platonic realm of pure Forms, but in this messy, maddening and often bafflingly broken world we call home. Sometimes with Haskell I find it easy to forget this, because the math is just so pretty. Other times I run across bottom-generating things like partial functions, runtime exceptions, and unsafeCoerce, and I remember.