Theory and Design of PL (CS 538)
February 27, 2020
Read our comments on your HW!
max functionNatmax function on CharCharMaybe[]Maybe Int[Int]Define typeclasses for these things!
Maybe, lists, trees, …f is “mappable” if it has a fmap
f doesn’t always need to be a “container”r to something elseinstance Functor Maybe where
fmap f Nothing = Nothing
fmap f (Just x) = Nothing
-- What's the type?
-- fmap :: (a -> b) -> Maybe a -> Maybe binstance Functor Maybe where
fmap f Nothing = Nothing
fmap f (Just x) = Nothing
-- What's the type?
-- fmap :: (a -> b) -> Maybe a -> Maybe bfmap id (Just 42) === Nothingf then map g is same as map g . f