ocaml-ppx / ppx_import

Less redundancy in type declarations and signatures
MIT License
89 stars 28 forks source link

How do [@with] replacements work with module types? #91

Open CPCTC opened 1 year ago

CPCTC commented 1 year ago

The documentation says:

For module types, the replacements are specified using the standard with construct.

Does that mean, like this?

(* a.ml *)
module type T = sig
    type t = string;;
end;;

(* b.ml *)
module type TT = [%import: (module A.T with type t = int)];;
module T: TT = struct
    type t = int
end;;

I tried that, but it doesn't look like any replacement is happening.

File "b.ml", lines 2-4, characters 15-3:
2 | ...............struct
3 |     type t = int
4 | end..
Error: Signature mismatch:
       Modules do not match: sig type t = int end is not included in TT
       Type declarations do not match:
         type t = int
       is not included in
         type t = string
       The type t is not equal to the type string
       File "a.ml", line 2, characters 4-19: Expected declaration
       File "b.ml", line 3, characters 4-16: Actual declaration