* Re: mutually dependent class and type
@ 2008-09-26 0:03 Jeff Shaw
2008-09-26 0:08 ` Jeff Shaw
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Shaw @ 2008-09-26 0:03 UTC (permalink / raw)
To: caml-list
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: mutually dependent class and type
2008-09-26 0:03 mutually dependent class and type Jeff Shaw
@ 2008-09-26 0:08 ` Jeff Shaw
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Shaw @ 2008-09-26 0:08 UTC (permalink / raw)
To: caml-list
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)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* mutually dependent class and type
@ 2008-09-25 22:24 Sébastien Hinderer
0 siblings, 0 replies; 3+ messages in thread
From: Sébastien Hinderer @ 2008-09-25 22:24 UTC (permalink / raw)
To: caml-list
Dear list,
Is there a (clean) way to define simultaneously a class and a type that
are mutually recursive ?
Something like this :
class element (c : content) =
object
...
end and type content =
| Data of string
| Elements of element list;;
This is of course not a valid OCaml definition, but is there a way to
express it ?
Many thanks in advance for your help,
Sébastien.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-26 0:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-26 0:03 mutually dependent class and type Jeff Shaw
2008-09-26 0:08 ` Jeff Shaw
-- strict thread matches above, loose matches on Subject: below --
2008-09-25 22:24 Sébastien Hinderer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox