Functor
and state its invariants.
data Expr op var = Var var | Lit Integer | OpAppl op [Expr Var]Define (and verify) a
Functor
instance for Expr op
.
class GenTerm t where genSubst :: t x -> (x -> t y) -> t yDefine a
GenTerm
instance for Expr op
.
GenTerm
instance for BinTree
,
with:
data BinTree a = Leaf a | BinTree a :^: BinTree a
GenTerm
instance for []
.
Hint: Use map
!
GenTerm
instance for Maybe
.
GenTerm
instance for
Data.Set.Set
(in class, a mathematical definition is sufficient).
GenTerm
instance for (->) c
.
GenTerm
instance for IO
.
(=>=) :: GenTerm t => (x -> t y) -> (y -> t z) -> (x -> t z)What are the properties you would expect for this composition?
In which of the above examples do they hold?