caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jerome Vouillon <Jerome.Vouillon@inria.fr>
To: Peter Schrammel <peter.schrammel@unibw-muenchen.de>,
	Pierre Weis <Pierre.Weis@inria.fr>,
	caml-list@inria.fr
Subject: Re: Tree of a certain class:
Date: Fri, 24 Sep 1999 14:35:24 +0200	[thread overview]
Message-ID: <19990924143524.57189@pauillac.inria.fr> (raw)
In-Reply-To: <37EB3338.4E226250@unibw-muenchen.de>; from Peter Schrammel on Fri, Sep 24, 1999 at 10:15:52AM +0200

On Fri, Sep 24, 1999 at 10:15:52AM +0200, Peter Schrammel wrote:
> I wrote a Program:
> type 'i tree =
>     Empty
>   | Item of 'i
>   | Section of 'i * 'i
> 
> class ['i] ctree =
>   object (self : 'a)
>     val mutable content : 'i tree = Empty
> 
>     method get = content
>         
> end
> 
> class debug =
>   object
>     method debug = ()
>   end
> 
> class dtree =
>   object
>     inherit [#debug] ctree
>   end
> 
> But the compiler gives me the error:
> 
> Some type variables are unbound in this type:
>   class dtree :
>     object val mutable content : (#debug as 'a) tree method get : 'a
> tree end
> The method get has type #debug tree where .. is unbound
> make: *** [test.cmo] Error 2   
> 
> How can make trees of a certain (sub)class ? (I hope there's a simple
> solution)

Depending on your needs, you can either write
    class dtree =
      object
        inherit [debug] ctree
    end
or
    class ['a] dtree =
      object
        constraint 'a = #debug
        inherit ['a] ctree
    end
In the first case, the type of the contained object is fixed. In the
second case it is only required to be an instance of type
   #debug = < debug : unit; .. >
So, if you write a subclass debug2 of class debug, an object of type
"debug2 dtree" will contain objects of type "debug2".

Regards,

-- Jérôme




      parent reply	other threads:[~1999-09-24 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-17  1:13 What am I missing? skaller
1999-09-17 12:44 ` Pierre Weis
1999-09-24  8:15   ` Tree of a certain class: Peter Schrammel
1999-09-24 12:06     ` Pierre Boulet
1999-09-24 12:18     ` Sylvain BOULM'E
1999-09-24 12:35     ` Jerome Vouillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990924143524.57189@pauillac.inria.fr \
    --to=jerome.vouillon@inria.fr \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=peter.schrammel@unibw-muenchen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).