Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: mutually dependent class and type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jeff Shaw <shawjef3@m...>
Subject: Re: mutually dependent class and type
I'm more sick than I thought. content_of_variant should have been 
variant_of_content, and I forgot to delete the double redundant semi-colon.

Jeff Shaw wrote:
> I don't know how you might directly get what you want, but here's one 
> way to get an equivalent result.
>
> class element_aux (c : [`Data of string | `Element of element list]) = 
> object end
>
> type content = Data of string | Element of element list;;
>
> let content_of_variant = function Data d -> `Data d | Element e -> 
> `Element e
>
> class element (c : content) = element_aux (content_of_variant c)
>