
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 etc But it's not very satisfactory because it adds a big new interface to TypeRep. Better ideas would be welcome. Simon | -----Original Message----- | From: libraries-bounces@haskell.org [mailto:libraries-bounces@haskell.org] On Behalf Of Dylan | Thurston | Sent: 06 April 2004 21:12 | To: libraries@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. | | Peace, | Dylan

On Wed, 2004-04-07 at 01:22, Simon Peyton-Jones wrote:
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.
Why not just document it as unspecified? There are already such expressions in the language; for instance, I would be astounded if all Haskell implementations gave the same answer for 'show (tan 1e20)'. Carl Witty
participants (2)
-
Carl Witty
-
Simon Peyton-Jones