Combining type constraints

Andrew J Bromage
Fri, 9 Aug 2002 11:54:00 +1000

G'day all.

I have a large number of functions all of which use the same set
of type constraints, such as:

 > foo :: (Monad m, Ord t, Show t) => ...

Ideally, I'd like to combine them into one typeclass.  At the moment,
I'm using the equivalent of:

 > class     (Monad m, Ord t, Show t) => Constraints m t  where { }
 > instance  (Monad m, Ord t, Show t) => Constraints m t  where { }

 > foo :: (Constraints m t) => ...

This requires undecidable instances.  Is there a way to do this that
doesn't require non-98 features apart from multi-parameter type

If not, is there an argument for a language construction which supports
this idiom, analogous to type synonyms, except for type classes?

Andrew Bromage