inheritance for functor ?

From: Christophe Raffalli (Christophe.Raffalli@univ-savoie.fr)
Date: Wed Aug 26 1998 - 10:27:21 MET DST


Date: Wed, 26 Aug 1998 10:27:21 +0200
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: caml-list@inria.fr
Subject: inheritance for functor ?

The "open" feature for module and module type does not add any
construtor to a module. It would be nice to also have an "inherit" or
"import" constructor that would add all the constructor of a module to
the current module.

Here si an example:

I could write this:

module type Ring =
  sig
   type t (*les elemnets de l'anneau seront de
type t*)
    val zero : t (*definition de l'element nul*)
    val one : t (*definition de l'unite*)
    val t_of_int : int -> t
    val (++) : t -> t -> t (*definition de la somme pour
l'anneau*)
    val (--) : t -> t -> t (*definition de la soustraction*)
    val ( ** ) : t -> t -> t (*definition de la multiplication*)
    val (==) : t -> t -> bool
    val opp: t -> t
    val print : t -> unit

  end

module type Field =
  sig
   import Ring
    val (//) : t -> t -> t
  end

module type Euclidian_Ring =
  sig
   import Ring
   type nt
    val norm : t -> nt
    val leq : nt -> nt -> bool
    val (//) : t -> t -> t
    val (mod) : t -> t -> t
    val div_mod : t -> t -> t * t
  end

This feature reflects more the intention of the programmer.

 

-- 
Christophe Raffalli
Laboratoire de Mathématique / LAMA
Université de Savoie
UFR SFA, Campus Scientifique
73376, Le Bourget du Lac CEDEX, FRANCE.

URL: http://www.logique.jussieu.fr/www.raffalli email: Christophe.Raffalli@univ-savoie.fr



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:15 MET