Created
March 10, 2014 20:44
-
-
Save david-hodgetts/9473902 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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