751 B
751 B
Natural Transformation Examples (4/4)
mToList :: Maybe a -> [a]
mToList Nothing = []
mToList Just x = [x]
toMaybe
is a natural transformation.
It is also a morphism from []
to Maybe
in the Category of \(\Hask\) endofunctors.
![natural transformation commutative diagram](/yogsototh/category-theory-presentation/media/commit/60135c86970a5ad0117afe51396bf7d9ff43a54c/categories/30_How/200_Monads/categories/img/mp/nattrans-maybe-list.png)
![relation between [] and Maybe](/yogsototh/category-theory-presentation/media/commit/60135c86970a5ad0117afe51396bf7d9ff43a54c/categories/30_How/200_Monads/categories/img/mp/maybe-list-endofunctor-morphsm.png)
Hint:
Bool
lists longer than 1.