A natural transformation: familly η ; \(η_X\in\hom{\D}\) for \(X\in\ob{\C}\) s.t.
ex: between Haskell functors; F a -> G a
Rearragement functions only.
data Tree a = Empty | Node a [Tree a]
-toTree :: [a] -> Tree a
-toTree [] = Empty
-toTree (x:xs) = Node x [toTree xs]
+data List a = Nil | Cons a (List a)
+toList :: [a] -> Tree a
+toList [] = Nil
+toList (x:xs) = Cons x (toList xs)
-toTree
is a natural transformation. It is also a morphism from []
to Tree
in the Category of \(\Hask\) endofunctors.
toList
is a natural transformation. It is also a morphism from []
to List
in the Category of \(\Hask\) endofunctors.
data Tree a = Empty | Node a [Tree a]
-toList :: Tree a -> [a]
-toList Empty = []
-toList (Node x l) = [x] ++ concat (map toList l)
+data List a = Nil | Cons a (List a)
+toHList :: List a -> [a]
+toHList Nil = []
+toHList (Cons x xs) = x:toHList xs
-toList
is a natural transformation. It is also a morphism from Tree
to []
in the Category of \(\Hask\) endofunctors.
toHList
is a natural transformation. It is also a morphism from List
to []
in the Category of \(\Hask\) endofunctors.