Skip to content

Instantly share code, notes, and snippets.

@LucianU
Created July 31, 2018 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucianU/41b8a92ae3fcde62b627a2c70aac47c4 to your computer and use it in GitHub Desktop.
Save LucianU/41b8a92ae3fcde62b627a2c70aac47c4 to your computer and use it in GitHub Desktop.
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