caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* What am I missing?
@ 1999-09-17  1:13 skaller
  1999-09-17 12:44 ` Pierre Weis
  0 siblings, 1 reply; 6+ messages in thread
From: skaller @ 1999-09-17  1:13 UTC (permalink / raw)
  To: caml-list

Why?

[root@ruby] ~/felix>ocamlc util.ml
[root@ruby] ~/felix>ocamlc util.mli
[root@ruby] ~/felix>ocaml
        Objective Caml version 2.02

# open Util;;
# string_of_list;;
Reference to undefined global `Util'
#





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: What am I missing?
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre Weis @ 1999-09-17 12:44 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

> Why?
> 
> [root@ruby] ~/felix>ocamlc util.ml
> [root@ruby] ~/felix>ocamlc util.mli
> [root@ruby] ~/felix>ocaml
>         Objective Caml version 2.02
> 
> # open Util;;
> # string_of_list;;
> Reference to undefined global `Util'

When you open a module you just add the list of exported names from
that module to your current environment (the interface of the module is
loaded). The corresponding implementation must be loaded (the code has
to be linked), before using any of the names defined in the
implementation. Use the pragma #load in the interactive environment to
link the code:

        Objective Caml version 2.02

# open Util;;
# #load"util.cmo";;
# string_of_list;;
- : 'a list -> string = <fun>

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Tree of a certain class:
  1999-09-17 12:44 ` Pierre Weis
@ 1999-09-24  8:15   ` Peter Schrammel
  1999-09-24 12:06     ` Pierre Boulet
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter Schrammel @ 1999-09-24  8:15 UTC (permalink / raw)
  To: Pierre Weis, caml-list

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)

Regards,
Peter
--
Peter Schrammel
UniBw-Muenchen 106/2/116
85579 Neubiberg
ICQ: 5469131




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tree of a certain class:
  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
  2 siblings, 0 replies; 6+ messages in thread
From: Pierre Boulet @ 1999-09-24 12:06 UTC (permalink / raw)
  To: peter.schrammel; +Cc: caml-list

> 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   
> 
Here is a simple solution: just write your class as:

class ['a] dtree =
  object
    constraint 'a = #debug
    inherit ['a] ctree
  end

Indeed, no type variable can stay unbounded (hence the ['a]) in a
class definition. #debug (equivalent to < debug : unit; .. >) is an
abbreviation that hides a type variable (the elipsis: ..).

-- 
Pierre.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tree of a certain class:
  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
  2 siblings, 0 replies; 6+ messages in thread
From: Sylvain BOULM'E @ 1999-09-24 12:18 UTC (permalink / raw)
  To: caml-list

Hello,

Actually, #debug is an abbrevation for 
 <method debug : unit; ..>
where ".." is a row type variable, you may imagine as universally quantified.
And methods of a class are not allowed to be polymorphic. Only classes are.
So, you have to bound this row variable to a type parameter of the class. 

* So a general solution is :

class ['a] dtree =
  object
    constraint 'a=#debug
    inherit ['a] ctree
  end

* But if you want only a "debug tree", you may write :

class dtree =
  object
    inherit [debug] ctree
  end

Regards,

Sylvain.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Tree of a certain class:
  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
  2 siblings, 0 replies; 6+ messages in thread
From: Jerome Vouillon @ 1999-09-24 12:35 UTC (permalink / raw)
  To: Peter Schrammel, Pierre Weis, caml-list

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-09-24 16:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).