【发布时间】:2010-11-26 03:37:27
【问题描述】:
半环模块中元素的类型是ElementS,它是一组元素。当我定义 zero = ElementS.empty 时,它说作为 type element ElementS.t
存在类型错误我找不到任何类似的问题,也无法解决这个问题。
(*semiring.ml*)
module type SEMIRING =
sig
type elements
type poly = elements polynomial
type variable = int
(** Constants **)
val zero : elements (** Identity for + **)
.....
end
module CountingSemiring : SEMIRING =
struct
module Ord : Carrier.Order =
struct
let vector_order= 2
end
module Z = Carrier.Make(Ord)
module ElementS = Set.Make(
struct
let compare = Pervasives.compare
type t = Z
end )
type elements = ElementS
type varmap = elements IntMap.t
type poly = elements polynomial
let zero = ElementS.empty
end
(* carrier.ml *)
module Make (Ord:Order) =
struct
let o = Ord.vector_order
type t = Elementi.t array
let gen i =
if( i < o) then
let arr = Array.make o (Elementi.N 0) in
Array.set arr i (Elementi.N 1)
else
failwith "Out of bound generate"
....
end
ERROR: Signature mismatch SEMIRING vs CountingSemiring Values do not match: val zero : ElementS.t is not included in val zero : elements when they should be the same.
【问题讨论】:
-
一个集合 S 和 S.empty 有不同的类型。在目前的情况下,有什么方法可以绕过这个限制?
标签: ocaml