summaryrefslogtreecommitdiff
path: root/functor/h5.hs
blob: 88bc79a074e64abb439240e1523a80e1f5825c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- The composition of two Functors is also a Functor.

import Data.Functor

newtype Comp f g a = Comp { unComp :: f (g a) }

compose :: f (g a) -> Comp f g a
compose = Comp

decompose :: Comp f g a -> f (g a)
decompose = unComp

instance (Functor f, Functor g) => Functor (Comp f g) where
  fmap f = compose . fmap (fmap f) . decompose