Type Classes and the StdEnv

Nick Kallen phantom@earthlink.net
Thu, 27 Nov 1997 13:41:12 -0800


I now understand exactly what's going wrong, and how to avoid it. But, I
think the slight annoyance of having do give Start a type is worth
it--considering the flexibility that a really polymorphic StdEnv would give.

Consider:

:: Env a b :== [(a, b)]

instance Map Env
map f env = [(x,f v) \\ (x,v) <- env]

or even:

::Tree a = (/\) infixl 0 (Tree a) (Tree a)
    | Leaf a

instance Map Tree
where
    map f (l/\r) = map f l /\ map f r
    map f (Leaf a) = Leaf (f a)

---

Certainly I'm not alone in thinking that's convenient. In fact, that map
function for a tree comes right out of (instance Functor Tree) from the
Reference Manual. Instead of (Class Map), the manual defines (Class
Functor). My request is that (Class Functor) or (Class Map) or whatever be
part of the StdEnv, and have map defined as an instance. It is more than
worth its costs in my oppinion. And, I think that this applies to more than
just map--there are other functions that would benefit from making them part
of a Class.