[
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: | 2008-07-11 (21:20) |
From: | Jeremy Yallop <jeremy.yallop@e...> |
Subject: | Re: [Caml-list] Troublesome nodes |
Dario Teixeira wrote: > Ideally, one could do something like this: > > type seq_t = super_node_t list > and nonlink_node_t = > [ `Text of string > | `Bold of seq_t ] > and link_node_t = > [ Mref of string * nonlink_node_t list > | See of string ] > and super_node_t = [nonlink_node_t | link_node_t] > > > However, this fails with an error "The type constructor nonlink_node_t is > not yet completely defined". Here's a slight variation of this scheme that might suit your needs. The idea is to move the recursion from the type level to the module level, sidestepping the restriction that you can't extend types in the same recursive group. module rec M : sig type seq_t = M.super_node_t list type nonlink_node_t = [ `Text of string | `Bold of seq_t ] type link_node_t = [ `Mref of string * nonlink_node_t list | `See of string ] type super_node_t = [ nonlink_node_t | link_node_t ] end = M Jeremy.