
On Mon, Sep 23, 2019, 3:05 PM Juan Casanova
data SOTermPF fn p f = ConstF fn | Proj Int | CompF p [f] deriving Eq
newtype SOTermF fn f = SOF (SOTermPF fn f f) deriving Eq
Here's a more modular option for the Traversable instance. import Data.Bitraversable import Data.Bifoldable import Control.Applicative import Data.Traversable instance Bifoldable (SOTermPF fn) where bifoldMap = bifoldMapDefault instance Bitraversable (SOTermPF fn) where bitraverse _f _g (ConstF fn) = pure (ConstF fn) bitraverse _f _g (Proj i) = pure (Proj i) bitraverse f g (CompF p fs) = liftA2 CompF (f p) (traverse g fs) instance Foldable (SOTermF fn) where foldMap = foldMapDefault instance Traversable (SOTermF fn) where traverse f (SOF q) = SOF <$> bitraverse f f q