From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 453D6BC37 for ; Wed, 30 Sep 2009 16:01:08 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8DAPMBw0pQRFuwWWdsb2JhbACadgEWFb1/hCcEgU0 X-IronPort-AV: E=Sophos;i="4.44,480,1249250400"; d="scan'208";a="37180754" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Sep 2009 16:01:07 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Mszjv-0002Lo-Ih for caml-list@inria.fr; Wed, 30 Sep 2009 15:01:07 +0100 Date: Wed, 30 Sep 2009 15:01:07 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] xpath or alternatives Message-ID: <20090930140107.GB5126@annexia.org> References: <20090930101622.GA15517@annexia.org> <245077.49646.qm@web111516.mail.gq1.yahoo.com> <20090930115723.GL1104@annexia.org> <20090930125904.GA5126@annexia.org> <9d3ec8300909300633t51db9ed9jf3ad15e6b0551c1e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9d3ec8300909300633t51db9ed9jf3ad15e6b0551c1e@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; ocamlduce:01 xduce:01 ocaml:01 ocamlduce:01 casts:01 runtime:01 ocaml's:01 subtyping:01 prerr:01 endline:01 prerr:01 endline:01 usr:01 model:01 2009:98 On Wed, Sep 30, 2009 at 09:33:07AM -0400, Till Varoquaux wrote: > OCamlduce (Alain correct me if I am wrong) basically maintains two > separate type systems side by side (the Xduce one and the Ocaml one). > This is done in order to make Ocamlduce maintainable by keeping a > clear separation. As a result you have to explicitly convert values > between type systems using {:...:}. These casts are type safe but do > lead to some work at runtime. > > Also note that ocaml's string are Latin1 and not String in the XML world. So: > > let devs = match xml with > | {{ [[[]]] }} -> {:dev:} > | {{ [[[]]] }} -> > {:file:} in > > Should work (I'm rusty and have nothing to check handy). I tried variations on the above, but couldn't get it to work. ocamlduce is very fond of a mysterious error called "Error: Subtyping failed", which is very difficult for me to understand, and therefore must be absolutely impossible for someone not used to strong typing. This is where I'm heading at the moment (sorry, my previous example missed a level inside ), so: let xml = from_string xml in prerr_endline (Ocamlduce.to_string xml); let devs = {{ map [xml] with | [[[_]]] | [[[_]]] -> [s] | _ -> [] }} in prerr_endline (Ocamlduce.to_string devs); +1 : this compiles -1 : it doesn't work, devs is empty This is what the first prerr_endline prints: [ [ 'CentOS5x32' ] [ '2ce397d9-1931-feb1-8ad8-15f22c4f18af' ] [ '524288' ] [ '524288' ] [ '1' ] [ [ 'hvm' ] [ ] ] [ [ ] [ ] [ ] ] [ ] [ 'destroy' ] [ 'restart' ] [ 'restart' ] [ [ '/usr/bin/qemu-kvm' ] [ [ ] [ ] ] [ [ ] [ ] [ ] ] [ [ ] [ ] ] [ [ ] [ ] ] [ ] [ ]