data Expr a = Lit a | Add (Expr a) (Expr a) | Expr a :* [Expr a] deriving stock (Show) extractPatternFunctor defaultRules ''Exprwill create
data ExprF a x = LitF a | AddF x x | x :*$ [x] deriving stock (Functor, Foldable, Traversable) instance Projectable (->) (Expr a) (ExprF a) where project (Lit x) = LitF x project (Add x y) = AddF x y project (x :* y) = x :*$ y instance Steppable (->) (Expr a) (ExprF a) where embed (LitF x) = Lit x embed (AddF x y) = Add x y embed (x :*$ y) = x :* y instance Recursive (->) (Expr a) (ExprF a) where cata φ = φ . fmap (cata φ) . project instance Corecursive (->) (Expr a) (ExprF a) where ana ψ = embed . fmap (ana ψ) . ψNotes: