OCaml前向声明

时间:2010-06-11 20:45:48

标签: types ocaml forward-declaration

有没有办法在OCaml中进行C风格的前向声明?

我的问题是我有两个互相引用的变体:

type path_formula =
  [ `Next of state_formula
  | `Until of (state_formula * state_formula)
  | `UntilB of (state_formula * int * state_formula)  
  ]

type state_formula = 
    [ `True | `False
    | `Not of state_formula
    | `And of (state_formula * state_formula)
    | `Or of (state_formula * state_formula)
    | `Imply of (state_formula * state_formula)
    | `Label of string
    | `Prob` of (boundf * path_formula)
    | `Expc` of (boundi * formula)
    ]

所以这两种类型都必须知道另一种类型..我在Google上搜索它但不幸的是OCaml不是那么广泛使用的编程语言..

1 个答案:

答案 0 :(得分:14)

使用

type T1 = ...
and T2 = ...

有递归类型。