Skip to content

Instantly share code, notes, and snippets.

@MiyamonY
Created February 28, 2015 11:57
Show Gist options
  • Save MiyamonY/e6a3a19fd156c5a2b187 to your computer and use it in GitHub Desktop.
Save MiyamonY/e6a3a19fd156c5a2b187 to your computer and use it in GitHub Desktop.
-- instance Functor ((->) r) where
-- fmap f g = (\ x -> f (g x))
-- instance Functor ((->) r) where
-- fmap = (.)
-- functor laws
-- first law
-- isntance Fucntor Maybe where
-- famp f (Just x) = Just (f x)
-- fmap f Nothing = Nothing
-- second law
data CMaybe a = CNothing | CJust Int a deriving (Show)
instance Functor CMaybe where
fmap f CNothing = CNothing
fmap f (CJust counter x) = CJust (succ counter) (f x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment