Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] New polymorphic variant syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Patrick M Doane <patrick@w...>
Subject: [Caml-list] New polymorphic variant syntax

On the Bedouin project, we are currently exploring ways to verify that
construction of HTML data will respect constraints specified in a DTD. We
recently tried using the new polymorphic variant syntax in the 3.03 alpha
version to represent entity references. For example:

type fontstyle = [ `Tt | `I | `B | `U | `S | `Strike | `Big | `Small ]
type inline = [ `Pcdata | fontstyle | ... ]
type flow = [ block | inline ]

Then HTML generating functions use a phantom type to track the DTD

val tt_ :
  ?id:string ->
  ?class_:string ->
  (* ... more attributes follow ... *)
  [< inline ] t list ->
  [> `Tt] t

Having abbreviations like 'inline' works really well. I'm curious to know
if there is a good way to represent the following information:

   <!ELEMENT FORM - - (%flow;)+ -(FORM)>

This states that a FORM element can have any flow object except for FORM
(i.e. nesting is not allowed).

How difficult would it be to extend the polymorphic variant syntax to list
tags that should not be included in the conjuction? Perhaps this already
possible? Of course we can always revert to simply listing the variants.

Thanks for the good work! This is much nicer to work with compared with


Bug reports:  FAQ:
To unsubscribe, mail  Archives: