Ord instance for TypeRep?
simonpj at microsoft.com
Wed Apr 7 10:22:39 EDT 2004
It's not as simple as it sounds. The difficulty is this:
Is typeOf (x::Int) > type (y::Bool)
If the semantics of the language is well defined, there should be an
answer, otherwise you could write programs in which different Haskell
implementations give different answers.
We could legislate lexicographic comparison based on the type
constructor names, but that's not very efficient and I'd rather not tie
the hands of the implementation.
This is an old chestnut that I really don't know a good solution too. A
not very good solution is this: if the reason for comparison is for
maps, provide maps
data TypeRepMap a
empty :: TypeRepMap a
insert :: TypeRepMap a -> TypeRep -> a -> TypeRepMap a
But it's not very satisfactory because it adds a big new interface to
Better ideas would be welcome.
| -----Original Message-----
| From: libraries-bounces at haskell.org
[mailto:libraries-bounces at haskell.org] On Behalf Of Dylan
| Sent: 06 April 2004 21:12
| To: libraries at haskell.org
| Subject: Ord instance for TypeRep?
| I'm not sure this is the right place to make this request, but could
| an instance of 'Ord TypeRep' please be added? I'd like to store
| dynamically typed elements in a FiniteMap.
More information about the Libraries