[Haskell-cafe] Data.Typeable TypeRep Ord instance.

Serguey Zefirov sergueyz at gmail.com
Sun Dec 5 00:59:11 CET 2010

2010/12/5 Tianyi Cui <tianyicui at gmail.com>:
> Why should they? You can compare them in whatever way you like. And there
> isn't a natural/inherent sense of total order between types.

I cannot compare then the way I'd like. ;)

Consider the following:

data BiMap a = BiMap {
     values :: Map Int a
    ,indices :: Map a Int

It will serve well for Int's, Bool's and Expr's.

Then I decided to store typed Expr's, based on GADTs. Those Expr's
contains type indices and it would be natural to classify BiMaps by
their type indices and look up in there. If I require type indices to
be Typeable, all I need is ordering on TypeRep.

Also, I prototyped hypergraph library with hyperedges as types with
type family as HList of types denoting labels. There I needed ordering
on TypeRep too, again, for efficiency reasons.

More information about the Haskell-Cafe mailing list