17 Aug
2018
17 Aug
'18
6:46 p.m.
In Scope.hs there are some functions I feel difficult to understand, Why fmap/foldmap/traverse is applied three times? instance Functor f => Functor (Scope b f) where fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a) {-# INLINE fmap #-} -- | @'toList'@ is provides a list (with duplicates) of the free variables instance Foldable f => Foldable (Scope b f) where foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a {-# INLINE foldMap #-} instance Traversable f => Traversable (Scope b f) where traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a {-# INLINE traverse #-}