-
Notifications
You must be signed in to change notification settings - Fork 233
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
Removing unused parameters when extracting (Invalid F# is generated by type definitions) #1096
Comments
This seems quite hard to solve. After erasure, in particular, we will have many cases where there are unused type variables after extraction. @A-Manning : I don't understand your |
type ('a, 'b) t = 'a // Not ok
type ('a, 'b) t = | T of 'a // Ok I have a custom version of F# compiler services that allows for type abbreviations of this form, I can share it if that would be helpful to others who want to extract F* to F#. |
Ok, that's what I was guessing you meant. I don't think adding these additional datatypes is going to fly. It'll require special treatment to project away the constructor elsewhere which is delicate and will also be inefficient. Also, it's very cool that you have a custom patch to F# to support this kind of stuff. But, I don't think using a custom version is really going to fly long term. In order to solve this properly it looks like we need to remove unused parameters when extracting. This would also be useful for the OCaml and KreMLin backends. But, it's non-trivial. Renaming the issue accordingly. |
I agree, it's a bad idea to be relying on a custom version of F# for this. I have a suggestion on fslang-suggestions regarding allowing erased types in F#.
It seems that erased types could become part of F#, which would remove the need to maintain a custom F# compiler. |
…for extraction to F#. cf. Issue #1096
F# won't accept type abbreviations that don't use all of the declared type parameters in the type being abbreviated, whereas OCaml will.
For example, OCaml will accept
type ('a, 'b) t = 'a
, whereas F# will result in an FS0035 error.These types come up frequently, since F* allows this style of type definition.
In FStar.Pervasives,
is extracted to
Since
'Aa
appears as a parameter ofst_wp_h
but not in the type abbreviation that it is defined by, the F# compiler throws FS0035.A workaround is to use single constructor DUs when defining types like this.
The text was updated successfully, but these errors were encountered: