From: "Bünzli Daniel" <daniel.buenzli@erratique.ch>
To: Alain Frisch <alain@frisch.fr>
Cc: caml-list List <caml-list@inria.fr>
Subject: Re: [Caml-list] xmlm and names(paces)
Date: Thu, 7 Feb 2008 00:51:23 +0100 [thread overview]
Message-ID: <0D5D170A-D29F-493D-94A6-610838E65624@erratique.ch> (raw)
In-Reply-To: <B227B75D-06FC-4F8F-9880-38FE4D32FF1F@erratique.ch>
Le 6 févr. 08 à 23:56, Bünzli Daniel a écrit :
> Of course this means more work for the client, but it makes the
> basic interface simpler and it allows the client
> to use variants instead of simply shorter prefixes.
Now that I think of it instead of (what I have now) :
> type name = string * string
> type attribute = name * string
> type tag = name * attribute list
>
> val input : ?enc:encoding option -> ?strip:bool ->
> ?ns: (string -> string option) ->
> ?entity: (string -> string option) ->
> ?prolog: (dtd -> unit) ->
> ?prune:(tag -> 'a -> bool) ->
> ?s:(tag -> 'a -> 'a) ->
> ?e:(tag -> 'a -> 'a) ->
> ?d:(string -> 'a -> 'a) -> 'a -> input ->
> [ `Value of 'a | `Error of (int * int) * error ]
(~s is for start tag, ~e is for end tag (the full start tag is given
again), ~d is for data)
Why not have a callback ~name which is given the expanded name
(uri,local) allows the client to do whathever it wishes and
a callback ~att to build attributes :
> val input : ?enc:encoding option -> ?strip:bool ->
> ?ns: (string -> string option) ->
> ?entity: (string -> string option) ->
> name: (string -> string -> 'n) ->
> att: ('n -> string -> 'att)
> ?prolog: (dtd -> unit) ->
> ?prune:('n * 'att -> 'a -> bool) ->
> ?s:('n * 'att list -> 'a -> 'a) ->
> ?e:('n * 'att list -> 'a -> 'a) ->
> ?d:(string -> 'a -> 'a) -> 'a -> input ->
> [ `Value of 'a | `Error of (int * int) * error ]
This allows you to give precise variant cases for the things your
process and have a catch all case for what you are not interested in.
Output would be polymorphised accordingly and the client provides
inverses of ~name ('n -> string * string) and ~att ('att -> 'n *
string).
On the other hand the work performed by ~name and ~att can be done by
the client in ~s or ~e. The only thing the latter solution brings is
to avoid folding over the tag type if you want to transform it. So
finally I don't think it is worth it (especially because the
polymorphised output feels cumbersome).
Any comment ?
Daniel
next prev parent reply other threads:[~2008-02-06 23:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-06 20:44 Bünzli Daniel
2008-02-06 20:59 ` [Caml-list] " David Teller
2008-02-06 21:26 ` Bünzli Daniel
2008-02-06 21:52 ` Alain Frisch
2008-02-06 22:56 ` Bünzli Daniel
2008-02-06 23:51 ` Bünzli Daniel [this message]
2008-02-07 22:03 ` Alain Frisch
2008-02-07 8:13 oleg
2008-02-07 8:59 ` [Caml-list] " Bünzli Daniel
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=0D5D170A-D29F-493D-94A6-610838E65624@erratique.ch \
--to=daniel.buenzli@erratique.ch \
--cc=alain@frisch.fr \
--cc=caml-list@inria.fr \
/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