From: Sven LUTHER <luther@maxime.u-strasbg.fr>
To: caml-list@inria.fr
Subject: module, module type et foncteurs, ...
Date: Fri, 22 Oct 1999 16:03:04 +0200 [thread overview]
Message-ID: <19991022160304.A27175@maxime.u-strasbg.fr> (raw)
Bonjour, ...
Je souhaite ecrire quelque chose du genre :
-----------------------------------------------------------
module A = struct
type a = A | B | C
let id (x : a) = x
end
module type T_A = sig
type a
val id : a -> a
end
module type T_A_detail = sig
type a = A | B | C
end
module type T_A_choisi = T_A
module type T_B = sig
type a
type b =
| TA of A.a
| TB of b
end
module type T_Make_B = functor (A : T_A_choisi) -> T_B
module Make_B (A : T_A_choisi) = struct
type a = A.a
type b =
| TA of A.a
| TB of b
end
module Make_C (A : T_A_detail) (Make_B : T_Make_B) = struct
let string_of_a = function
| A.A -> "A"
| A.B -> "B"
| A.C -> "C"
end
module B2 = Make_B (A)
module C2 = Make_C (A) (Make_B)
let rec string_of_b = function
| B2.TA a -> B2.string_of_a a
| B2.TB b -> string_of_b b
-----------------------------------------------------------
Mais j'obtient l'erreur suivante :
-----------------------------------------------------------
File "exemple.ml", line 35, characters 24-30:
Signature mismatch:
Modules do not match:
functor(A : T_A_choisi) ->
sig type a = A.a and b = Make_B(A).b = | TA of A.a | TB of b end
is not included in
T_Make_B
Modules do not match:
sig type a = A.a and b = Make_B(A).b = | TA of A.a | TB of b end
is not included in
T_B
Type declarations do not match:
type b = Make_B(A).b = | TA of A.a | TB of b
is not included in
type b = | TA of A.a | TB of b
-----------------------------------------------------------
Est-ce normal, que ce passe-t-il exactement. Y a-t-il une autre maniere
de faire la meme chose ?
Je ne comprend pas qu'elle est la difference entre
type b = Make_B(A).b = | TA of A.a | TB of b
et
type b = | TA of A.a | TB of b
D'un autre cote est-ce qu'un type de tableau de booleens qui serait represente de
maniere efficace existe ? on aurrait un bit par booleen, et non un int comme cela est
fait actuellement.
J'imagine qu'on peut faire cela en definissant un type de tableau d'entier, et aller
voir la valeur de chaque bit de ces entiers.
Amicalement,
Sven LUTHER
next reply other threads:[~1999-10-25 15:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-22 14:03 Sven LUTHER [this message]
1999-10-29 8:46 ` Xavier Leroy
1999-11-02 9:14 ` Judicael Courant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19991022160304.A27175@maxime.u-strasbg.fr \
--to=luther@maxime.u-strasbg.fr \
--cc=caml-list@inria.fr \
--cc=luther@dpt-info.u-strasbg.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox