type level sets is something I really, really would like to have because it’s sometimes my first thought but then immediately followed by “ugh, but they’re not available”. I just created an account just for this reply I have some thoughts, but they are super amateurish because I really have no experience with interacting with GHC.
I don’t think the “type level lists as sets” is the way to go. Not ergonomic.
I think they are doable as a compiler plugin, I would prefer not use type-families because they are so slow, but one can always improve later. There is already a first idea here on how to compare types, it’s on GitHub from isovector (type-sets is the repo called)
While I personally have never ever interacted with GHC, I am really quite interested in this and so have a rough idea how to do it, although it might be impossible because of details unknown to me. And some things I am not sure about.
I think we needs several ingredients:
One major question I am really unsure about is the syntax-sugar, which I think is essential. It’s just too unergonomic otherwise. You can just provide a “to data structure” type-level function if you’re really interested what’s currently behind the sugar.
I think parsing sytanx sugar is doable with the approach mentioned, but will it always display it this way? I think every basic function acting on the syntax-sugar would need to be implemented as a GHC-Plugin because we want to “hide” the under the HsExpansion
mentioned here in the wiki above? Or is there some other way?
I would be really interested whether my approach is realistic. I completely expect it to be a lot of work and just lack any real experience for this. But in principle this would lead to a first-class type-set like thing…right?