-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Singletons for Data.Functor.Product.Product? #448
Comments
My goal is to be able to turn the type |
You're not doing anything wrong per se. It's more that In particular, instance (SingKind a_1, ..., SingKind a_n) => SingKind (D a_1 ... a_n) where
type Demote (D a_1 ... a_n) = D (Demote a_1) ... (Demote a_n)
fromSing = ...
toSing = ... This works fine as long as instance SingKind a => SingKind (Const a b) where
type Demote (Const a b) = Const (Demote a) b
fromSing = ...
toSing = ... We are able to get away with using instance SingKind (Product f g a) where
type Demote (Product f g a) = Product f g a
fromSing (SPair sfa sga) = Pair (fromSing sfa) (fromSing sga)
toSing = ... This will fail to compile thusly:
Is all hope lost? Not necessarily. You can just as well omit the generation of $(withOptions defaultOptions{genSingKindInsts = False} (genSingletons [''Product])) But since you explicitly mentioned that you wanted to use |
Thank you for the very thorough explanation! Before even looking at singletons, I did just have this: class ToValue (a :: k) where
value :: k type class, and that seemed to work. I could define an instance of this for |
Indeed, I think you may have to stick with the |
There is an interesting conversation starting here about how one might define a
|
This seems to be left out of the Prelude stuff, but I'm also unable to run
genSingletons
on this type:Produces
Am I doing something wrong, or missing a language extension?
The text was updated successfully, but these errors were encountered: