Home

From Category Theory for Programmers - Series 1

Category Theory 9.1 - Natural transformations

 
-- | head is a function that takes a list and returns the first element
-- | safe head to check for empty list
safeHead :: [a] -> Maybe a
safeHead [] = Nothing
safeHead (x : xs) = Just x
-- | parametrically polymorphic, same function for all types
-- | alphab ∘ fmapF f = fmapG g ∘ alphaa

(part 2)