Browse thread
Extracting common information
-
Niko Matsakis
- Romain
- Bünzli_Daniel
- skaller
- Stephen Weeks
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Bünzli_Daniel <daniel.buenzli@e...> |
| Subject: | Re: [Caml-list] Extracting common information |
Another solution is to use polymorphic variants [1] :
type 'ud type_tree = [ `Primitive of 'ud * string |
`Pointer of 'ud * 'ud type_tree ]
type 'ud expr_tree = [ `Unary of 'ud * string * 'ud expr_tree |
`Binary of 'ud * string * 'ud expr_tree * 'ud
expr_tree ]
type 'ud any_tree = [ 'ud type_tree | 'ud expr_tree ]
let ud = function
| `Primitive (ud, _) | `Pointer (ud, _) | `Unary (ud, _, _) | `Binary
(ud, _, _, _) -> ud
Daniel
[1] http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html#htoc41