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