Chapter 16 Outline¶
16.1 Functor
16.2 What’s a functor?
16.3 There’s a whole lot of fmap goin’ round
16.4 Let’s talk about f baby
16.4.1 Shining star come into view
16.4.2 Exercises: Be Kind
1
2
3
16.4.3 A shining star for you to see
16.4.4 Functor is function application
16.4.5 A shining star for you to see what your f can truly be
16.4.6 Type classes and constructor classes
16.5 Functor Laws
16.5.1 Identity
16.5.2 Composition
16.5.3 Structure preservation
16.6 The Good, the Bad, and the Ugly
16.6.1 Composition should just work
16.7 Commonly used functors
16.7.1 The functors are stacked and that’s a fact
16.7.2 What if we lift twice?
16.7.3 Wait, how does that even typecheck?
16.7.4 Lift me baby one more time
16.7.5 The real type of thing going down
16.7.6 Get on up and get down
16.7.7 One more round for the P-Funkshun
16.7.8 Stay on the scene like an fmap machine
16.7.9 Exercises: Heavy Lifting
16.8 Transforming the unapplied type argument
16.9 QuickCheck Functor instances
16.10 Exercises: Instances of Func
1
2
3
4
5
6
7
8
16.11 Ignoring possibilities
16.11.1 Maybe
16.11.2 Exercise: Possibility
16.11.3 Either
16.11.4 Short Exercise
1
2
16.12 A somewhat surprising functor
16.13 More structure, more functors
16.14 IO Functor
16.15 What if we want to do something different?
16.16 Functor are unique to a datatype
16.17 Chapter exercises
These exercises do not have titles, like previous chapters, but they do have subordinate elements, so I’m listing the problem description here, instead.
16.17.1 Determine if a valid Functor can be written for the datatype provided
1
2
3
4
5
16.17.2 Rearrange the arguments to the type constructor of the datatype so the functor instances works.
1
2
3
16.17.3 Write Functor instances for the following datatype
1
2
3
4
5
6
7
8
9
10
11
16.18 Definitions
Higher-kinded polymorphism
Functor
Lifting
George Clinton (the musician)
16.19 Follow-up resources
Haskell Wikibook; The Functor Class
Mark P. Jones; A system of constructor classes: overloading and implicit higher-order polymorphism
Gabriel Gonzalez; The functor design pattern