caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* module, module type et foncteurs, ...
@ 1999-10-22 14:03 Sven LUTHER
  1999-10-29  8:46 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Sven LUTHER @ 1999-10-22 14:03 UTC (permalink / raw)
  To: caml-list

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-11-03 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-22 14:03 module, module type et foncteurs, Sven LUTHER
1999-10-29  8:46 ` Xavier Leroy
1999-11-02  9:14   ` Judicael Courant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).