caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: gaurav_chanda@lycos.com
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] Pxp objects inside class definition
Date: Tue, 09 Jul 2002 14:20:35 +0200	[thread overview]
Message-ID: <3D2AD513.1010500@gerd-stolpmann.de> (raw)
In-Reply-To: <BGDGFLPILNAGEAAA@mailcity.com>

Gaurav Chanda wrote:
> Hello
> 
> I am using the Polymorphic XML Parser (PXP) to parse XML documents. I have made 2 files : point.ml and point.mli, which contain simple class definitions.
> 
> The file point.mli contains:
> 
> open Pxp_yacc ;
> open Pxp_document ;
> open Pxp_types ;
> 
> class type point_sig =
>         object
>                 value mutable x : Pxp_document.node 'a;
>         end;
> 
> class point : point_sig ;
> 
> 
> The file point.ml contains:
> 
> open Pxp_yacc ;
> open Pxp_document ;
> open Pxp_types ;
> 
> class type point_sig =
>         object
>                 value mutable x : Pxp_document.node 'a;
>         end ;
> 
> value def = "<def></def>" ;
> value def = parse_wfdocument_entity default_config (from_string def) default_spec ;
> value defr = def#root ;
> 
> class point:point_sig =
>         object
>                 value mutable x = defr;
>         end;
> 
> I get an error message while compilation. My compilation command is : 
> ocamlopt -pp "camlp4r pa_extend.cmo" -I +camlp4 -I Ty/ -I /usr/lib/ocaml/site-lib/netstring -I /usr/lib/ocaml/site-lib/pxp-engine  -I /usr/lib/ocaml/site-lib/pxp-lex-iso88591/ -c point.mli point.ml
> 
> 
> The error message is : 
> 
> File "point.ml", line 15, characters 8-67:
> The class type
>   object
>     val mutable x :
>       ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
>   end
> is not matched by the class type point_sig
> The class type
>   object
>     val mutable x :
>       ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
>   end
> is not matched by the class type
>   object
>     val mutable x :
>       ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node
>   end
[...]
> 
> I am not being able to define PXP objects inside classes. Could you help me solve this problem ?

Hi Garuav,

(the following in classic syntax)

the problem is that  'a Pxp_document.node  is not the full type, because 
there is a constraint on the parameter of the class Pxp_document.node,
and the compiler correctly augments the type such that it reads
('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node.
However, defr has the type
('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node,
which is not the same. This is all the long error message wants to tell
you.

The solution is quite simple: Use the complete type instead of
'a Pxp_document.node, i.e.

class type point_sig =
object
   val mutable x :
    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
end

Sorry that the types of PXP are that complicated.
('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
reflects the fact that nodes have extensions, and the extensions are
recursively bound to their nodes. This is sometimes a bit unhandy.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
------------------------------------------------------------

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2002-07-09 12:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-09  8:35 Gaurav Chanda
2002-07-09 12:20 ` Gerd Stolpmann [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=3D2AD513.1010500@gerd-stolpmann.de \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@pauillac.inria.fr \
    --cc=gaurav_chanda@lycos.com \
    /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).