3
这只是一个简单的程序,我写的是为了更好地理解模块。我试图用Id("a",Int)
来调用toS
函数,但是好像我可以写这样的ast类型。可能是什么问题?OCaml这个函数应用于太多的参数
module Typ =
struct
type typ = Int | Bool
end
module Symbol =
struct
type t = string
end
module Ast =
struct
type ast = Const of int * Typ.typ | Id of Symbol.t * Typ.typ
let rec toS ast = match ast with Id(a,b) -> "a"
|_->"b"
end
Ast.toS Id("a",Int)
或ocaml的> = 3.12:__Ast(TOS(ID( “A”,Typ.Int)))__ – Kakadu
谢谢!这解决了我的问题 – otchkcom