Tree insert, lookup with keys
Ketil Z. Malde
ketil@ii.uib.no
20 Dec 2002 11:16:19 +0100
Ingo Wechsung <iw@contexo.de> writes:
> 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