签名不匹配

时间:2010-11-26 03:37:27

标签: ocaml

半环模块中的元素类型是ElementS,它是一组元素。当我定义零= ElementS.empty时,它表示类型错误为类型元素<> 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.

1 个答案:

答案 0 :(得分:2)

type elements = ElementS

这可能是一个错字:您将元素定义为具有一个常量构造函数ElementS的和类型。

编译器告诉您此类型与ElementS.t不兼容。所以你应该写:

type elements = ElementS.t