unique id for data types

Simon Peyton-Jones simonpj at microsoft.com
Tue Sep 18 11:21:14 EDT 2007

You're asking for something tricky here.

|  >      type family NameCmp n m
| which totally orders datatypes. More precisely, it should return one
| of the following types:
|  >      data NameLT = NameLT
|  >      data NameEQ = NameEQ
|  >      data NameGT = NameGT

Now, whenever you declare a new data type T, you want, magically, the following instances to spring to life

        type instance NameCmp T Int = NameLT
        type instance NameCmp T Bool = NameLT
        ..etc etc etc...

Obviously there would be way too many instances. So you really want a built-in magic type family NameCmp, which does what you want.

Furthermore, the behaviour should be predicatable across compilers; so you'd need to specify just what the result should be in a compiler-independent way.

Well I suppose you might do that (via lexical comparison of fully-qualified names), but it's clearly An Extension.  Type-families alone get nowhere near.


More information about the Glasgow-haskell-users mailing list