I suggest we ...

Allow implementation of abstract slots with generic return type instantiated at type 'unit'

The behavior described here,

http://stackoverflow.com/questions/26296401/why-is-unit-treated-differently-by-the-f-type-system-when-used-as-a-generic-i

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<unit> 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.

7 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Eric Stokes shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

Approving this in principle, it would be great to fix this behavior.

We will open an RFC on this in due course, https://github.com/fsharp/FSharpLangDesign/tree/master/RFCs

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

0 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

F# Language

Feedback and Knowledge Base