I am experimenting with the module language of OCaml (3.12.1), defining functors and signatures for modules and so on, mostly following the examples from Chapter 2 of the OC
Your key error was here:
module IntType : SOMETYPE = struct type t end ;;
When you ascribe the signature SOMETYPE
, it's an opaque ascription, and the identity with int
is lost. Type IntType.t
is now an abstract type.
You need instead to ascribe the signature SOMETYPE with type t = int
.
This transcript shows the difference:
# module type SOMETYPE = sig type t end;;
module type SOMETYPE = sig type t end
# module IntType : SOMETYPE with type t = int = struct type t = int end;;
module IntType : sig type t = int end
# module AbsType : SOMETYPE = struct type t = int end;;
module AbsType : SOMETYPE
The language-design issues around modules and ascription are well covered in the lead designer's 1994 paper on modules, types, and separate compilation. The hairy math parts can all be skipped.