Skip to content

Instantly share code, notes, and snippets.

@rexcfnghk
Created October 9, 2022 14:30
Show Gist options
  • Save rexcfnghk/bd1513bdeb92f354a614877ed5d5868c to your computer and use it in GitHub Desktop.
Save rexcfnghk/bd1513bdeb92f354a614877ed5d5868c to your computer and use it in GitHub Desktop.
instance Functor [] where
fmap _ [] = []
fmap f (x::xs) = f x :: fmap f xs
instance Functor Maybe where
fmap _ Nothing = Nothing
fmap f (Just x) = Just (f x)
instance Functor (Either a) where
fmap _ x@(Left _) = x
fmap f (Right x) = Right (f x)
instance Functor (-> a) where
fmap = (.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment