A Generic Ordering over Types

Hello, I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic: https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/.... I was considering submitting it to Hackage if anyone finds this useful. I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types. The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic. I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise? Cheers, Justin

Cool approach! cmptype does something similar, but requires a ghc plugin: https://github.com/isovector/type-sets/tree/master/cmptype I suppose one advantage of cmptype is that it can work with types that cannot derive Generic, such as GADTs. -Michael On Sat, Dec 28, 2019 at 3:23 AM Justin Paston-Cooper < paston.cooper@gmail.com> wrote:
Hello,
I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic:
https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/... . I was considering submitting it to Hackage if anyone finds this useful.
I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types.
The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic.
I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise?
Cheers,
Justin _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Looks like cmptype wins on genericity. Out of interest, is there any
alternative these days to writing the tuple instances of CmpType
explicitly?
On Sat, 28 Dec 2019 at 23:29, Michael Sloan
Cool approach!
cmptype does something similar, but requires a ghc plugin: https://github.com/isovector/type-sets/tree/master/cmptype
I suppose one advantage of cmptype is that it can work with types that cannot derive Generic, such as GADTs.
-Michael
On Sat, Dec 28, 2019 at 3:23 AM Justin Paston-Cooper
wrote: Hello,
I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic: https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/.... I was considering submitting it to Hackage if anyone finds this useful.
I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types.
The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic.
I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise?
Cheers,
Justin _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I'm not sure why cmptype lists the tuple instances explicitly, since the plugin also handles tuple types. I can delete those cases and it still passes the tests. -Michael On Sun, Dec 29, 2019 at 12:51 AM Justin Paston-Cooper < paston.cooper@gmail.com> wrote:
Looks like cmptype wins on genericity. Out of interest, is there any alternative these days to writing the tuple instances of CmpType explicitly?
On Sat, 28 Dec 2019 at 23:29, Michael Sloan
wrote: Cool approach!
cmptype does something similar, but requires a ghc plugin:
https://github.com/isovector/type-sets/tree/master/cmptype
I suppose one advantage of cmptype is that it can work with types that
cannot derive Generic, such as GADTs.
-Michael
On Sat, Dec 28, 2019 at 3:23 AM Justin Paston-Cooper <
paston.cooper@gmail.com> wrote:
Hello,
I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic:
https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/... .
I was considering submitting it to Hackage if anyone finds this useful.
I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types.
The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic.
I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise?
Cheers,
Justin _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Very nifty! Could you/should you add function types? Those are never
Generic, so you could check for them first.
On Sat, Dec 28, 2019, 5:22 AM Justin Paston-Cooper
Hello,
I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic:
https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/... . I was considering submitting it to Hackage if anyone finds this useful.
I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types.
The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic.
I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise?
Cheers,
Justin _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

My idea was to support Generic types only.
On Sat, 28 Dec 2019 at 23:37, David Feuer
Very nifty! Could you/should you add function types? Those are never Generic, so you could check for them first.
On Sat, Dec 28, 2019, 5:22 AM Justin Paston-Cooper
wrote: Hello,
I've defined a module which defines a Data.Type.Ordering over types which are instances of Generic: https://github.com/jpcooper/generic-type-ordering/blob/master/src/Data/Type/.... I was considering submitting it to Hackage if anyone finds this useful.
I am using it in conjunction with Data.Type.Set (type-level-sets), which requires an ordering over the used types.
The ordering works by first comparing the package, then the module, then the type name. I take it that the ordering as defined is correct over all types which are an instance of Generic.
I wanted to check first whether this is done anywhere else, or in a different, better way. Can anyone advise?
Cheers,
Justin _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (3)
-
David Feuer
-
Justin Paston-Cooper
-
Michael Sloan