ocsigen / eliomlang

Runtime and tools for the eliom language
ISC License
9 stars 1 forks source link

Lift module types when lifting ground modules. #16

Closed Drup closed 7 years ago

Drup commented 8 years ago

This doesn't work at the moment:


module%server A = struct
  type t = int * string fragment
  let compare (x,y) (x',y') = compare x x'
end

module%server B = Map.Make(A)

The issue is that Map.Make expects a module in scope base, not in scope server. We need to lift the module type into the server scope when lifting the module itself.

Drup commented 8 years ago

This is also causing issues for a much simpler (and quite more common) pattern, in a .mli:

module type M = sig
  ...
end 

include%server M
Drup commented 8 years ago

I have a prototype fix which repurpose Ident.rename, which has for consequence that Subst will shift things to the current side.... This is not extremely clean.

Drup commented 8 years ago

test case that exercises this:

module type%client S = sig
  type t
  val make : int -> char -> t
end

module%client M = String

module%client F (M : S) = struct type t = M.t * M.t end
module%client X = F(String)
module%client Y = F(M)

module%client N = struct
  type t = int * string
  let compare = compare
end

module%client SN = Map.Make(N)

let%client x : string = M.make 3 'f'
Drup commented 7 years ago

This works and is much cleaner now.