Skip to content
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

Better implementation of side-switch for type expressions #14

Open
Drup opened this issue Jun 29, 2016 · 2 comments
Open

Better implementation of side-switch for type expressions #14

Drup opened this issue Jun 29, 2016 · 2 comments
Labels

Comments

@Drup
Copy link
Member

Drup commented Jun 29, 2016

At the moment, side-switch happens when a type expression of the form foo Eliom_fragment.t. It doesn't work with aliases. More problematic, even if we were to resolve aliases, there is still the issue of abstract types that contains some client fragments (type 'a t = { foo : int ; bar : ('a * string) Eliom_fragment.t }).

One proposition to resolve this is to use a similar mechanism to variance: it's correctly propagated by the compiler and annotate type variables. For a given type constructor, we just need to lookup the type declaration to know we should switch side.

@Drup Drup added the Typing label Jun 29, 2016
@Drup
Copy link
Member Author

Drup commented Jul 26, 2016

This is now implemented with explicit annotations on the type parameters.

For example, in (client side) Eliom_fragment:

type +'a[@client] t

I don't think it's a good idea to have any inference for this (as opposed to variance annotations). This works also for multiple parameters: type ('a, 'b[@client], 'c) t.

Currently, it is not very tested. In particular the relation to type variable and unification might need tweaking. Oh, and it's completely unchecked (very bad). WIP.

One (big) problem is that I had to change the typedtree for this, which is something I carefully avoided until now. It might be possible to work around that with some more annotations.

@Drup
Copy link
Member Author

Drup commented Jan 1, 2017

This is now implemented with attributes on the typedtree and is checked both inside a type declaration and for module inclusion.

One remaining issue is the interaction with with type in module.

This is accepted (and should not):

module type S = sig
  type 'a[@client] x
end

module type SX =
  S with type 'a[@client] x = 'a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant