我有这个模块类型:
module type MOD =
sig
type operand
type op
val print : op -> string
end;;
Run Code Online (Sandbox Code Playgroud)
MOD的实现是:
module M1:MOD =
struct
type operand = Mem of int | Reg of int | Const of int
type op = Add of operand * operand| Sub of operand * operand
let print op = match op with
| Add _ -> "Add"
| Sub _ -> "Sub"
end;;
Run Code Online (Sandbox Code Playgroud)
我想创建一个参数化模块,op从第一个模块获取类型,并在该类型的变量上实现函数.像这样:
module ARCHI = functor (M : MOD) ->
struct
type …Run Code Online (Sandbox Code Playgroud)