caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
Cc: OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] Expansion of type-constructors in ctype.ml
Date: Tue, 25 Aug 2015 23:02:38 +0900	[thread overview]
Message-ID: <3A6D9855-8FCD-4345-983D-011DD5138C0E@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <55DAEEDA.6020709@tu-berlin.de>

On 2015/08/24 19:15, Christoph Höger wrote:
> 
> find attached a patch against the 4.02.3 tree that solves my issue with
> compiling the problematic examples.
> 
> I am pretty confident that the change to eqtype is sound, I do not know
> exactly what moregen() is intended to do, though and it seems that its
> side-effects are required (that is why I expand the types there in any
> case).
> 
> I appreciate any further comments,
> 
> Christoph

Do you mean that modifying moregen and eqtype (but not unify)
in a conservative way would be enough to solve your problem?
Then indeed we could do that.
At least your code for eqtype seems fine. For moregen, this is not sufficient, due to non-local side effects.
By the way, we should keep your example around to prevent regressions.

On 2015/08/24 15:22, Christoph Höger wrote:
> Am 24.08.2015 um 00:18 schrieb Jacques Garrigue:
>> This is indeed a pretty difficult problem, as you must be careful of not
>> changing the semantics of unification.
>> Until recently, the only solution was to expand the type, as there was
>> no static information cacheing whether an argument was used in the
>> body or not.
>> However, since relatively recent changes about variance information
>> (the switch to 7 flags…), we actually have at least an approximation
>> of which unifications must be done imperatively, and which needn’t
>> be done at all.
>> So it might be doable at least for part of the parameters.
> 
> That sounds interesting. What are the relevant variance flags?
> 
You should read the following paper:
http://www.math.nagoya-u.ac.jp/~garrigue/papers/injectivity.pdf

If all the flags were always correct then it would be simple: any flag being
set would mean that the variable really appears in the type, so you must
recurse on it (at least for eqtype and moregen).
However, variance inference for the result of functors is not exact,
meaning that to be sure that a variable will not disappear, you must check
that inj is set (meaning that there is a concrete occurence).
In a nutshell:
may_pos and may_neg are both unset (i.e. nothing is set) => no need to recurse
inj is set => must recurse
otherwise => must expand

 Jacques Garrigue

  reply	other threads:[~2015-08-25 14:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-22  7:42 Christoph Höger
2015-08-22  9:23 ` Jeremy Yallop
2015-08-22 11:41   ` Christoph Höger
2015-08-23 22:18     ` Jacques Garrigue
2015-08-24  6:22       ` Christoph Höger
2015-08-24 10:15         ` Christoph Höger
2015-08-25 14:02           ` Jacques Garrigue [this message]
2015-08-25 15:47             ` Christoph Höger
2015-08-26  1:26               ` Jacques Garrigue
2015-11-05 11:29   ` Goswin von Brederlow

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=3A6D9855-8FCD-4345-983D-011DD5138C0E@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=christoph.hoeger@tu-berlin.de \
    /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).