caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Charles.Bouillaguet@crans.org
Cc: caml-list@yquem.inria.fr, romain.bardou@wanadoo.fr
Subject: Re: [Caml-list] Recursive Variant problem..
Date: Mon, 15 May 2006 21:40:07 +0900 (JST)	[thread overview]
Message-ID: <20060515.214007.35474922.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20060515.202355.105436069.garrigue@math.nagoya-u.ac.jp>

> From: Charles Bouillaguet <Charles.Bouillaguet@crans.org>
> > The problem appear when I want to define my values :
> > 
> > type 'sort array_state = 'sort * [`ArrayStateVar of string |  
> > `ArrayWrite of 'me  * 'sort base_value * [`Int] base_value * 'sort  
> > base_value] as 'me
> > and 'sort base_value = 'sort * [`Inert of unit | `FieldRead of  
> > [`Object] base_value * 'sort field | `ArrayRead of 'sort array_state  
> > * ('sort array_) base_value * [`Int] base_value]
> > and 'sort field = 'sort * [`FieldVar of string | `FieldWrite of 'me *  
> > [`Object] base_value * 'sort base_value] as 'me

> The trouble is that the array case takes 'sort as a parameter, meaning
> that we would need an infinity of such duplicates.
> Here is the second problem: by nature, polymorphic variants only allow
> regular types (that can be represented by a regular graph), and your
> definitions do not represent a regular type (you can get ever deeper
> arrays.)

Note that this can be solved by introducing a nominal type (record or
sum type) that breaks the irregular cycles. Here the following is
sufficient.

type 'sort array_state =
    'sort *
    [ `ArrayStateVar of string
    | `ArrayWrite of
        'me  * 'sort base_value * [`Int] base_value * 'sort base_value] as 'me
and 'sort base_value =
    {sort: 'sort; desc:
     [ `Inert of unit
     | `FieldRead of [`Object] base_value * 'sort field
     | `ArrayRead of
        'sort array_state * ('sort array_) base_value * [`Int] base_value]}
and 'sort field =
    'sort *
    [ `FieldVar of string
    | `FieldWrite of 'me *  [`Object] base_value * 'sort base_value] as 'me

Probably this is not you wanted, but just to make things clear.

Jacques Garrigue


      reply	other threads:[~2006-05-15 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-14 12:22 Charles Bouillaguet
2006-05-15  8:09 ` [Caml-list] " Stephane Glondu
2006-05-15 11:23 ` Jacques Garrigue
2006-05-15 12:40   ` Jacques Garrigue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060515.214007.35474922.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=Charles.Bouillaguet@crans.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=romain.bardou@wanadoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).