[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 1998-08-19 (23:41) |
From: | Sven LUTHER <LUTHERSV@e...> |
Subject: | Types construits et interface de modules |
Bonjour, ... Hello, ... est -il possible de faire la chose suivante en caml ? is it possible to do something like that in caml ? module type T = sig type t = A | B end module A = struct type t = A | B end module B = struct type t = A | B | C end module F (M:T) = struct type t = M.t end module MA = F (A) module MB = F (B) cela ne marche pas car les types t = A | B et t = A | B | C sont differents this don't work because the types t = A | B and t = A | B | C are different cependant il est possible de faire : module type T = sig type t val a : t val b : t end module A = struct type t = A | B let a = A let b = B end module B = struct type t = A | B | C let a = A let b = B let c = C end module F (M:T) = struct type t = M.t let a = M.a let b = M.b end module MA = F (A) module MB = F (B) en, quoi les constructeurs de types sont-ils differents des fonctions ? Ils ne sont pas propres a chaque type (en effet dans type t = A | B type t' = A | C, t'.A ecrase t.A). Il serait interressant de pouvoir definir automatiquement les constructeurs dans l'interface du module. in what are the type constuctors different from function symbols ? they don't belong only to the corresponding type, but to the whole module. it would be nice to be able to define also the type constructors in the interface of a module. module A = struct type t = A |B end aurrais le type : would have the following type : sig type t val A : t val B : t end Est ce que cela pose des probleme grave, ou ne s'agit-il que de sucre syntaxique autour de l'implementation actuelle ? Would this bring serious problems, or is it just syntaxic sugar over the actual state of things ? Amicalement, Sven LUTHER