Skip to content

Instantly share code, notes, and snippets.

@LucianU

LucianU/compose.hs

Created Jul 31, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.