
20 Dec
2002
20 Dec
'02
5:16 a.m.
Ingo Wechsung
class Keyed a where { -- Type a is keyed if it has a key function. key :: Ord b => a -> b; -- key is a function, that, when applied to a yields some b that is comparable }
But it isn't obvious what b is supposed to be. Try multi-parameter type classes e.g. class (Ord b) => Keyed a b where key :: a -> b (I'm possibly messing up the placement of the 'Ord b' qualifier)
and then
data Sym = Sym String Int Ty; -- Ty is another algebraic type instance Keyed Sym String where key (Sym a _ _) = a
(Requires -fglasgow-exts) -kzm -- If I haven't seen further, it is by standing in the footprints of giants