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
Annotated trees
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-06-07 (12:01)
From: blue storm <bluestorm.dylc@g...>
Subject: Re: [Caml-list] Annotated trees
On Mon, Jun 7, 2010 at 11:22 AM, Daniel Bünzli
<> wrote:
> That's true and certainly a good argument for the second form if you
> already know the type of your annotations and have such needs. However
> if you want to keep that polymorphic (the annotation is a convenience
> for the client) it results in a type variable per case which becomes
> heavy.

You probably know that already but there is a nice use of object types
as "type-level records" that make that kind of "lots of type
variables" situations tractable :

type 'annot tree =
 | Leaf of 'leaf_annot * string
 | Node of 'node_annot * 'annot tree list
constraint 'annot =
 < leaf : 'leaf_annot;
   node : 'node_annot >