Skip to content

Instantly share code, notes, and snippets.

@david-hodgetts
Created March 10, 2014 20:44
Show Gist options
  • Save david-hodgetts/9473902 to your computer and use it in GitHub Desktop.
Save david-hodgetts/9473902 to your computer and use it in GitHub Desktop.
-- fmap :: (a -> b) -> f a -> f b
-- (.) :: (b -> c) -> (a -> b) -> a -> c
-- (a -> b) -> (e -> a) -> e -> b
--
instance Functor ((->) e) where
fmap g h = g . h
-- (e, v) where e is an annotation and v a value
instance Functor ((,) e) where
fmap f ((,) e v) = ((,) e (f v))
instance Functor (Either e) where
fmap _ (Left x) = Left x
fmap f (Right v) = Right $ f v
class Functor f => Pointed f where
pure :: a -> f a
instance Pointed ((->) e) where
pure a = \ e -> a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment