-
Notifications
You must be signed in to change notification settings - Fork 563
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
Allow synonyms in some instance heads? #2529
Comments
I would be happy with (2) :) |
Yep, that's a better way of putting it! |
I'm in favor of allowing instances for fully-applied synonyms, but I'm not sure if the functional dependency rule makes sense, since we can't guarantee everything will be fully applied after solving: class WithDep a b | a -> b where
withDep :: Proxy1 a -> Proxy1 b
type A a = Either a String
instance example :: WithDep (Either String) A where
withDep Proxy1 = Proxy1 Here, we've somehow created a proxy for the type level function |
Using |
Ok, then I don't understand (1). I agree that synonyms must be fully applied in any case. |
1 would be something like: Take these: type T = X String
data F a Disallow this, because it's making an instance "directly" for a synonym: instance thing :: C T where ... Allow this: instance thing :: C (F T) where ... As It's the kind of instance that you'd probably rarely need to make except in a multiparam fundep-like situation anyway, as |
Actually, I think we should either allow neither or both of these. If we allow both, it would be because the synonym is fully applied in both cases, but the user would need to understand that it's just a shorthand, and not changing the behavior of the solver at all. |
Yeah, and that's my worry - as if you allow |
I think there may be two places where it may be reasonable to accept synonyms in instance heads:
I have a case where both these conditions coincide:
So here I have to use
Mu CursorF
inrecursiveX
, but with either of the rules above I'd be able to useCursor
in there instead.The main reason we don't allow synonyms in instances is so there's no confusion if people try to do that directly for a
type
rather than usingnewtype
, right? If so, I think the above cases still preserve that, and make some fancier use cases more convenient.Thoughts?
The text was updated successfully, but these errors were encountered: