私は OCaml の次のファンクターの問題にかなり悩まされています。理解できるように、コードの一部を貼り付けます。基本的
でこれら 2 つのモジュールを定義しましたpctl.ml
。
module type ProbPA = sig
include Hashtbl.HashedType
val next: t -> (t * float) list
val print: t -> float -> unit
end
module type M = sig
type s
val set_error: float -> unit
val check: s -> formula -> bool
val check_path: s -> path_formula -> float
val check_suite: s -> suite -> unit
end
および次のファンクタ:
module Make(P: ProbPA): (M with type s = P.t) = struct
type s = P.t
(* implementation *)
end
次に、これらのモジュールを実際に使用するために、次の名前のファイルに新しいモジュールを直接定義しましたprism.ml
。
type state = value array
type t = state
type value =
| VBOOL of bool
| VINT of int
| VFLOAT of float
| VUNSET
(* all the functions required *)
3 番目のソース ( ) から、モジュールformulas.ml
でファンクターを使用しました。Prism
module PrismPctl = Pctl.Make(Prism)
open PrismPctl
そして最後からmain.ml
open Formulas.PrismPctl
(* code to prepare the object *)
PrismPctl.check_suite s.sys_state suite (* error here *)
そしてコンパイルすると、次のエラーが発生します
エラー: この式にはタイプ Prism.state = Prism.value 配列がありますが、タイプ Formulas.PrismPctl.s の式が予期されていました
私が理解できることから、名前の一種の悪いエイリアシングがあり、それらは同じvalue array
です(型がとして定義され、ファンクターでt
使用さM with type s = P.t
れているため)が、型チェッカーはそれらを同じとは見なしません。
どこに問題があるのか 本当にわかりません。誰か助けてもらえますか?
前もって感謝します