We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a0e1c77 commit fe39782Copy full SHA for fe39782
src/ComposingTypes/Twinplicative/Exercise.hs
@@ -0,0 +1,13 @@
1
+module ComposingTypes.Twinplicative.Exercise where
2
+
3
+import Control.Applicative (liftA2)
4
5
+newtype Compose f g a = Compose { getCompose :: f (g a) }
6
+ deriving (Eq, Show)
7
8
+instance (Functor f, Functor g) => Functor (Compose f g) where
9
+ fmap f (Compose fga) = Compose $ (fmap . fmap) f fga
10
11
+instance (Applicative f, Applicative g) => Applicative (Compose f g) where
12
+ pure = Compose . pure . pure
13
+ Compose fgab <*> Compose fga = Compose $ liftA2 (<*>) fgab fga
0 commit comments