Version française
Home     About     Download     Resources     Contact us    
Browse thread
Troublesome nodes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Zheng Li <zheng_li@u...>
Subject: Re: Troublesome nodes
Hi,

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".  Jon Harrop suggested untying the recursive
> knot, but the solution has a few drawbacks of its own [2].

How about just define

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 =
       [`Test of string |`Bold of seq_t | `Mref of string * 
nonlink_node_t list | `See of string]

or similar ... not sure whether this satisfies your requirements though.

--
Zheng