Last active
June 26, 2016 03:51
-
-
Save ion1/18acf9350c40404f81e01e7708820fcd 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
((a -> b) -> c) -> (d -> (e -> f)) | |
-> | |
/ \ | |
-> -> | |
/ \ / \ | |
-> c d -> | |
/ \ / \ | |
a b e f |
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
import Data.Functor.Contravariant | |
data Foo a = Foo (a -> Integer) | |
data Bar a = Bar ((a -> Integer) -> Integer) | |
data Baz a = Baz (((a -> Integer) -> Integer) -> Integer) | |
foo :: (b -> a) -> (a -> Integer) -> (b -> Integer) | |
foo f g = _ | |
bar :: (a -> b) -> ((a -> Integer) -> Integer) -> ((b -> Integer) -> Integer) | |
bar f g = _ | |
baz :: (b -> a) -> (((a -> Integer) -> Integer) -> Integer) -> (((b -> Integer) -> Integer) -> Integer) | |
baz f g = _ | |
instance Contravariant Foo where | |
contramap f (Foo g) = Foo (foo f g) | |
instance Functor Bar where | |
fmap f (Bar g) = Bar (bar f g) | |
instance Contravariant Baz where | |
contramap f (Baz g) = Baz (baz f g) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment