Created
July 31, 2018 08:24
-
-
Save LucianU/41b8a92ae3fcde62b627a2c70aac47c4 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
newtype Identity a = | |
Identity { runIdentity :: a } | |
deriving (Eq, Show) | |
newtype Compose f g a = | |
Compose { getCompose :: f (g a) } | |
deriving (Eq, Show) | |
instance (Functor f, Functor g) => | |
Functor (Compose f g) where | |
fmap f (Compose fga) = | |
Compose $ (fmap . fmap) f fga | |
instance (Applicative f, Applicative g) => | |
Applicative (Compose f g) where | |
pure :: a -> Compose f g a | |
pure a = undefined | |
(<*>) :: Compose f g (a -> b) | |
-> Compose f g a | |
-> Compose f g b | |
(Compose f) <*> (Compose a) = Compose (f a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment