-
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
RE: Visible Type Applications #4436
Conversation
Just pointing out that this would be a breaking change, as far as i understand? Not sure if that is a big deal or not, but something to keep in mind. |
@artemisSystem It depends. The breaking change here would come from the new syntactic forms which determines if a type is available for type application or not. I think that having them on by default for class heads and data declarations is reasonable to allow for usage w/o introducing more friction. I can also imagine the latter being another additive feature, but I'm just not sure how to achieve that syntactically yet. Maybe, something along the lines of: class Visibility a where
visibility :: Invisible a => a -> a
-- or `visibility :: invisible a. a -> a`? where |
I think the errors you added should be unified to a "monomorphic/not-visibly-polymorphic type cannot have a type application". It would be great if those had separate error text based on whether it is polymorphic or not: “cannot type-apply the monomorphic type I think the current behavior of Will take a look at more of the logic later. |
Co-authored-by: Mark Eibes <mark.eibes@gmail.com>
An expression of polymorphic type | ||
with the invisible type variable [33ma[0m: | ||
[33m [0m | ||
[33m forall a. a -> a[0m | ||
[33m [0m | ||
cannot be applied to: | ||
[33m [0m | ||
[33m Int[0m | ||
[33m [0m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error can be expanded further by suggesting that the user can change the signature of the inferred type to allow it to be used in type application.
I think that for polymorphic types, it's the case that they're often written out by the user such that we can suggest editing the source, but I feel we can clarify this in the error index for the documentation page.
My approval above means it's my opinion that it's better to merge this in its current state now than not to merge it. If it does implement the feature while not handling edge cases or other situations properly, it's not like we don't have other useful language features that have their own years-long-standing edge-case bugs. To me, the net gain of a language feature that mostly works, especially one as highly desired as this one, is better than the possible downsides. Moreover, by getting it merged, it provides feedback on what edge cases this PR may still not yet resolve or other design situations not yet considered. But, because I know that others are more qualified when it comes to reviewing this part of the codebase, I'm choosing not to merge this at this time despite all our usual constraints being satisfied otherwise. On one hand, I may just be struggling with politician's syllogism, and maybe the real issue to further discuss are design questions not yet answered in the linked issue (of which I can't recall whether there were such issues, nor what those are). On the other hand, I do think that, if no one objects to merging this, that I will merge this sometime in the future. |
It's been a month since my previous comment. Since no one has objected, I'm merging. |
It's so cool! Following #3137 (comment), I used a shorter synonym for p :: ∀ @l r1 r2 r a b. IsSymbol l ⇒ Cons l a r r1 ⇒ Cons l b r r2 ⇒ Lens (Record r1) (Record r2) a b
p = prop (Proxy @l)
type St = {someField :: Int }
st :: St
st = { someField : 1}
ip :: Int
ip = view (p @"someField") st |
Actually I tried to shorten the function and drop the proxy parameter from prop'
:: forall @l r r1 r2 a b
. IsSymbol l
=> Row.Cons l a r r1
=> Row.Cons l b r r2
=> Lens { | r1 } { | r2 } a b
prop' = do
let p = Proxy @l
lens (Record.get p) (flip (Record.set p))
_test
:: forall r36 a37 b38 p
. Strong p
=> p a37 b38
-> p { test :: a37 | r36 } { test :: b38 | r36 }
_test = prop' @"test" The problem is that by default compiler derived a type for _test
:: forall r r1 r2 a b
. IsSymbol "test"
=> Row.Cons "test" a r r1
=> Row.Cons "test" b r r2
=> (forall p. Strong p => p a b -> p (Record r1) (Record r2)) Compiler error:
I think that this is unexpected behavior. Should I fill in a bug report for that? |
The error you see with that inferred type is already filed as #3243 |
Description of the change
Closes #3137, closes #4235. An alternative implementation of visible type applications that simplifies the type-checking rules and extraneous features. This PR also depends on #4376.
Like mentioned, this PR simplifies the type-checking rules used for visible type applications, as well as the extraneous features that come with #4235. In particular, the following is true for this implementation:
@
is still required for making type variables available under type application;IIRC, a few other features that were brought up were:
Though, I feel that:
As a reply to @mikesol's
Checklist: