[Haskell-cafe] unique id for data types

Neil Mitchell ndmitchell at gmail.com
Tue Sep 18 10:00:26 EDT 2007


Hi Barney,

This may be of interest, since all types already have an Int
associated with them:

http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Typeable.html#v%3AtypeRepKey

Thanks

Neil


On 9/18/07, Barney Hilken <b.hilken at ntlworld.com> wrote:
> In order to make my records system practically useable, I need a type
> family
>
>  >      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
>
> for each pair of datatypes n & m, according to whether n < m, n = m,
> or n > m
> in some global ordering. This ordering needs to be independent of the
> context,
> so it can't be affected by whatever imports there are in the current
> module.
>
> What I want to know is: does GHC give datatypes any global id I could
> use to
> generate such an ordering? Would fully qualified names work?
>
> Secondly (assuming it's possible) how easy would it be for me to
> write a patch
> to add NameCmp to GHC? Where in the source should I start looking?
>
> Thanks,
>
> Barney.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list