Ich habeWie umfasst die Arbeit?
module type T = sig
type t
end
und
module Make (TypeProvider : T) = struct
include TypeProvider
type d = Wrapped of t
end
und
module Test = struct
include Make (struct type t = ForWrap end)
let f = function | Wrapped ForWrap ->()
end
Ich stellte mir vor-Test nach der Kompilierung wie
module Test = struct
type t = ForWrap
type d = Wrapped of t
let f = function | Wrapped ForWrap ->()
end
Aber in real, es ist nicht übersetzbar c Ode. OCaml sagt mir:
module Test = struct
include Make (struct type t = ForWrap end)
let f = function | Wrapped ForWrap ->()
^^^^^^^
Error: Unbound constructor ForWrap
end
Und ich kann nicht verstehen, warum. Was ist das Problem in meiner Lösung?
Funktor-Anwendung ist eine Laufzeitoperation, und Sie können '' include'' nicht als reinen syntaktischen Ebenenersatz behandeln – objmagic