* [Caml-list] Recursive polymorphic variants
@ 2012-04-10 13:51 Gabriel Kerneis
2012-04-10 13:57 ` David House
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Kerneis @ 2012-04-10 13:51 UTC (permalink / raw)
To: caml-list
Hi list,
why is this definition allowed:
type t = [`A of t]
but the following one fails:
type t = [`A of [t|`B]]
Error: The type constructor t is not yet completely defined
Is there any work-around?
(My actual example is much larger and complex but I think it boils down to this
simple case.)
Many thanks,
--
Gabriel Kerneis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Recursive polymorphic variants
2012-04-10 13:51 [Caml-list] Recursive polymorphic variants Gabriel Kerneis
@ 2012-04-10 13:57 ` David House
2012-04-10 14:39 ` Romain Bardou
0 siblings, 1 reply; 3+ messages in thread
From: David House @ 2012-04-10 13:57 UTC (permalink / raw)
To: Gabriel Kerneis; +Cc: caml-list
On Tue, Apr 10, 2012 at 2:51 PM, Gabriel Kerneis <kerneis@pps.jussieu.fr> wrote:
> Is there any work-around?
Depending on your requirements, just wrapping up the recursive copy of
[t] in another constructor might do:
type t = [ `A of [ `B | `C of t ]]
I don't know why your original example is disallowed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Recursive polymorphic variants
2012-04-10 13:57 ` David House
@ 2012-04-10 14:39 ` Romain Bardou
0 siblings, 0 replies; 3+ messages in thread
From: Romain Bardou @ 2012-04-10 14:39 UTC (permalink / raw)
To: caml-list
Le 10/04/2012 15:57, David House a écrit :
> On Tue, Apr 10, 2012 at 2:51 PM, Gabriel Kerneis<kerneis@pps.jussieu.fr> wrote:
>> Is there any work-around?
>
> Depending on your requirements, just wrapping up the recursive copy of
> [t] in another constructor might do:
>
> type t = [ `A of [ `B | `C of t ]]
>
> I don't know why your original example is disallowed.
>
I think the semantic of [t|...] is just to syntactically replace t by
its definition, which is not possible if the definition is not done yet.
Cheers,
--
Romain Bardou
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-10 14:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10 13:51 [Caml-list] Recursive polymorphic variants Gabriel Kerneis
2012-04-10 13:57 ` David House
2012-04-10 14:39 ` Romain Bardou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox