For records with fields that have named (implicit, regular named) parameters the generated selector methods fails to type-check. For instance
data T = { x : {~n:Int} -> Unit }
fails with the following error.
fatal error: Cannot resolve an implicit parameter ~n
-> test.fram
1 |>data T = { x : {~n:Int} -> Unit }
Similarly, when we replace ~n with n. For optional parameters it works, but not as one would expect.
The problem is that the generated method x looks like the following (modulo some non-important type annotations).
To solve this problem, the generated method should explicitly generalize named parameters from the filed, and use the to reisntantiate the field. For instance:
method x {~n=_freshIdent42 : Int} (T { x }) = x {~n=_freshIdent42}
The following observations might be useful.
- Identifiers used to store named parameters should not collide with other variables. For instance
data T = { x : {x : Int} -> Unit } cannot generate method x {x : Int} (T { x }) = x { x }.
- Type annotations are important, and cannot be inferred in general. For instance
data T = { x : {n : {X} -> X} -> Unit } cannot generate method x {n} (T { x }) = x { n }, because the type-checker cannot guess polymorphic types.
- For type parameters, the type-checker should be able to infer missing information, but it would be nice to preserve names of named typed parameters.
For records with fields that have named (implicit, regular named) parameters the generated selector methods fails to type-check. For instance
fails with the following error.
Similarly, when we replace
~nwithn. For optional parameters it works, but not as one would expect.The problem is that the generated method
xlooks like the following (modulo some non-important type annotations).To solve this problem, the generated method should explicitly generalize named parameters from the filed, and use the to reisntantiate the field. For instance:
The following observations might be useful.
data T = { x : {x : Int} -> Unit }cannot generatemethod x {x : Int} (T { x }) = x { x }.data T = { x : {n : {X} -> X} -> Unit }cannot generatemethod x {n} (T { x }) = x { n }, because the type-checker cannot guess polymorphic types.