Coq中的模块错误类型不同

Coq中的模块错误类型不同,coq,Coq,我很难想出如何写这段代码 例如,我有一个签名a,一个函子C将a:a作为参数,为了能够使用C,我定义了一个模块B实现签名a Require Import String. Module Type A. Parameter toto : string -> nat. End A. Module C (Import a : A). ... End C. Module B <: A. Definition toto (s: string) := foo s. End B

我很难想出如何写这段代码

例如,我有一个签名
a
,一个函子
C
a:a
作为参数,为了能够使用
C
,我定义了一个模块
B
实现签名
a

Require Import String.
Module Type A.
  Parameter toto : string -> nat. 
End A.

Module C (Import a : A).
 ...
End C.

Module B <: A.
      Definition toto (s: string) := foo s.
End B. (* COQ error *)
我将在
D

我理解这个问题,因为我没有在
toto
的定义中提供
string list
参数

所以我的问题是我不知道在这种情况下如何提供参数
字符串列表

在我的真实代码中,我使用了
部分
记录
类型,而不是
模块

Record A : Type := mkA { too : string -> nat}.
然后我打开一个
部分

Section B.
 Variable l: string list.
 Definition too (s: string) := foo s l.
 Definition A := mkA too.
End B.

你能帮我写或者理解如何在模块中正确地写函子
B
?是否有一种方法可以在模块中定义/声明变量
string list
?同样,在
Coq
中定义之后,我将把它提取到
OCaml

您始终可以这样做:

Require Import String.

Parameter foo: string -> list string -> nat.

Module Type A.

  Parameter toto : string -> nat. 

End A.

Module B <: A.

  Variable (* or Parameter, or Axiom *) ls : list string.

  Definition toto (s: string) := foo s ls.

End B.

但这可能不是你需要的。没有上下文,很难给你更好的建议。

我两种方法都试过了。我选择了第二个,因为第一个有一个[Variable/…],它将在提取后生成一个[failthwith“Axiom…”。我的问题是第二个选择,我无法在Ocaml中定义签名[HasListString]的实现[ls],以便能够使用模块[B]中的函数。[ls]只是我真实代码中的一种类型。
Require Import String.

Parameter foo: string -> list string -> nat.

Module Type A.

  Parameter toto : string -> nat. 

End A.

Module B <: A.

  Variable (* or Parameter, or Axiom *) ls : list string.

  Definition toto (s: string) := foo s ls.

End B.
ModuleType HasListString.

  Parameter ls : list string.

End HasListString.

Module B(LS: HasListString) : A.

  Definition toto (s: string) := foo s LS.ls.

End B.