I am new to OCaml and I am struggling a bit with understanding how module types work.
module type I = sig type tendmodule EQ (M : I) = struct let equal (x : M.t) (y : M.t) = x = yend(* Explicitly type declaration *)module A : I = struct type t = stringendmodule EStr1 = EQ (A)(* Error: This expression has type string but an expression was expected of type A.t *)let _ = EStr1.equal "1" "0" |> string_of_bool |> print_endline(* No type declaration *)module B = struct type t = stringendmodule EStr2 = EQ (B)(* OK. Outputs false *)let _ = EStr2.equal "1" "0" |> string_of_bool |> print_endline
In the code above i declared module type I, module A with explicit module type declaration and module B without module type declaration. EQ is functor that recieves module of type I and returns module with equal method.Example with module A result in compiling error, while other works as i expected. What is semantic difference between this examples?