English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Extending a class constrained in a signature
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-17 (10:45)
From: Jean Balthazar <jean.balthazar.fr@g...>
Subject: Extending a class constrained in a signature
Dear OCamlers (again !),

I tried this time to specify explictly what I expect from a container. This
specification is given by the signature CONTAINER below. Everyhting works
perfectly but I don't understand why it fails if I remove the 'private'
keyword... Why
am I only able to extend an object when the type have the 'private' keyword
in its definition?

Is it possible to achieve the same behaviour using a class type rather a row
with private keyword?

All the best,

module type CONTAINER =

  type 'elt container = private < hd : 'elt; .. >

module Check = functor(Coll : CONTAINER) -> struct end

module Seq =

  class ['elt] container (arg : 'elt list) =
  object(self : 'selftype)

    method hd  = List.hd arg
    method tl  = new container (List.tl arg)



module CheckSeq = Check(Seq)