680 B
680 B
Natural Transformation Examples (1/4)
data Tree a = Empty | Node a [Tree a]
toTree :: [a] -> Tree a
toTree [] = Empty
toTree (x:xs) = Node x [toTree xs]
toTree
is a natural transformation.
It is also a morphism from []
to Tree
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-list-tree.png)
![natural transformation commutative diagram](/yogsototh/category-theory-presentation/media/commit/60135c86970a5ad0117afe51396bf7d9ff43a54c/categories/30_How/200_Monads/categories/img/mp/list-tree-endofunctor-morphism.png)