Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
From: Jean Balthazar <>
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 ( arg)



module CheckSeq = Check(Seq)