-
Notifications
You must be signed in to change notification settings - Fork 22
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 implementation of abstract slots with generic return type instantiated at type 'unit' #25
Comments
(adding old approval comment) Approving this in principle, it would be great to fix this behavior. We will open an RFC on this in due course, though this is not yet high priority. There are reasons for the existing behaviour due to unit v. void, as explained in the various stackoverflow topics on this question, but it should be possible to workaround those. Don Syme, F# Language Evolution |
When implementing such a method
we would presumably need to emit two methods:
Tailcalls would be lost, because of the need to discard the "FSharpUnit" value The logical place to add the method would be as soon as possible after type checking, so that duplicate method signature detection operates without change. There isn't a specific phase that's best for that, however, since there is no phase that "transforms" the TAST prior to duplicate method detection Adding the method during typechecking is not possible because we may not yet have inferred that the abstract slot return type is being instantiated to "unit" |
Closing this as we won't be addressing this specific technical limitation, it is not a significant problem in practice. |
Submitted by Eric Stokes on 1/8/2016 12:00:00 AM
7 votes on UserVoice prior to migration
The behavior described here is quite surprising to someone coming from other typed FP languages. The fact that a generic type parameter can't be unit makes the whole generics abstraction feel a bit leaky and hacky, which isn't great publicity, as F# actually has a lot of great ideas.
In practice this comes up when implementing type indexed values of various sorts, as an interface is an ideal and natural way to do that, and of course one often wants to have a sometype value. The compiler error is rather surprising as well, as it implies the object expression doesn't implement the interface, which of course isn't the case.
Original UserVoice Submission
Archived Uservoice Comments
The text was updated successfully, but these errors were encountered: