Fix chapter 25

master
Gaël Depreeuw 6 years ago
parent 3a1d972300
commit 0c1f5319e0
  1. 10
      25-composing-types/25-composing-types.md
  2. 2
      25-composing-types/25.4-twinplicative.md
  3. 5
      25-composing-types/25.6-compose-instances.md
  4. 5
      25-composing-types/src/gotcha.hs

@ -0,0 +1,10 @@
# 25 Composing Types
## 25.4 Twinplicative
see [src/gotcha.hs](./src/gotcha.hs)
## 25.6 Compose Instances
- see [src/gotcha.hs](./src/gotcha.hs)
- see [src/bifunctor.hs](./src/bifunctor.hs)

@ -1,2 +0,0 @@
# GOTCHA! Exercise time
see src/gotcha.hs

@ -1,5 +0,0 @@
# Exercises: Compose Instances
see src/gotcha.hs
## Bifunctor
see src/bifunctor.hs

@ -16,6 +16,11 @@ 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
myApply :: (Applicative f, Applicative g)
=> Compose f g (a -> b) -> Compose f g a -> Compose f g b
myApply (Compose h) (Compose c) =
Compose $ (fmap (<*>) h) <*> c
instance (Applicative f, Applicative g) => Applicative (Compose f g) where
pure :: a -> Compose f g a
pure a = Compose $ pure (pure a)

Loading…
Cancel
Save