I am reading the nice Category Theory for Programmers book from Bartosz Milewski (https://github.com/hmemcpy/milewski-ctfp-pdf/). I would like to check my solutions to exercises, but I did not find anything online on Challenge 6 of section 2.7. I am copying the exercise here:
Draw a picture of a category whose only objects are the types Void, () (unit), and Bool; with arrows corresponding to all possible functions between these types.
In case the notation is not clear (I'm not sure how much of it is specific to Haskell or this book, vs. standard math notation), here are some definitions taken from the book:
Voidis the empty set.()orunitdenotes a singleton set.Booldenotes a set with two elements.
Also, type can be taken as equivalent to a mathematical set.
Here is my solution:
Is it correct? In particular, I'm confused about Void. Should we allow functions that return Void?

It’s mostly correct. But, as you already suspected, there are no functions from other types to
Void, since every element has to be mapped to something, and there’s nothing to map it to in the void. Your arrow fromVoidtoVoidis right, though, since the void domain doesn’t contain any elements that would have to be mapped to the non-existent elements of the void co-domain.Also, there should be only one arrow from
VoidtoBool, as there’s only one way not to map any elements toBool.The general expression for the number of functions from $X$ to $Y$ is $|Y|^{|X|}$, since there are $|X|$ function values to choose, with $|Y|$ choices in each case. (Here $0^0$ needs to be defined as $1$ to make the expression work for functions from
VoidtoVoid.)