caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] Request for feedback: A problem with injectivity and GADTs
Date: Sat, 4 May 2013 09:09:06 +0200	[thread overview]
Message-ID: <CAPFanBHo64JUMkpcx5D+yKNVLnbRuF1jCVZ0B8oE=1Li=fkq-g@mail.gmail.com> (raw)
In-Reply-To: <44ACA8B7-8DCC-4948-8D8A-7C7A7FB0B4AF@math.nagoya-u.ac.jp>

> One way to solve this is to check that the type identified by 'a can
> actually be handled as a real variable (its internal variables do
> not occur out of it), which would solve the discrepancy.

If I understand correctly, you are saying that this "constraint", in
absence of injectivity, could be handled semantically like GADTs with
non-injective equations, that is as quantifying locally on a ("true")
existential variable?

Handling existential variables (in fact local type constructors)
attached to GADT constructors is well-understood as they have clear
introduction sites and scopes, exactly where their constructor is
matched. When you say that checking the "constraint" case is painful,
is it related to the fact that there is no such corresponding
term-level marker?

On Sat, May 4, 2013 at 8:46 AM, Jacques Garrigue
<garrigue@math.nagoya-u.ac.jp> wrote:
> On 2013/04/30, at 14:45, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>
>> I have now committed in trunk a fix to PR#5985.
>> You can use it to test whether your codebase runs into problems.
>> You can either obtain it from subversion directly
>>       svn checkout http://caml.inria.fr/svn/ocaml/trunk
>> or use opam to do it for you.
>>
>> I checked that at least Core itself compiles without problems.
>
> Ironically, I have just found that lablgtk2 does not compile with the fixed version.
> lablgtk2 does not use GADTs, but it uses constrained type parameters in classes.
>
> The problem is as follows:
>
> gobject.mli:
> type -'a gobj
>
> gContainer.mli:
> class virtual ['a] item_container :
>   object
>     constraint 'a = < as_item : [>`widget] obj; .. >
>     method add : 'a -> unit
>     …
>   end
>
> File "gContainer.mli", line 126, characters 6-665:
> Error: In this definition, a type variable cannot be deduced
>        from the type parameters.
>
> It is a bit surprising, since the said variable is the row variable
> of the above [> `widget], and it is only referred through 'a.
> The reason there is an error is that the checkability requirements
> for the body of types and constrained type parameters differ:
> to allow the row variable to appear in a position potentially
> contravariant, we need it to know from the constraint that it
> appears for sure in a negative or invariant position.
> One way to solve this is to check that the type identified by 'a can
> actually be handled as a real variable (its internal variables do
> not occur out of it), which would solve the discrepancy.
> However, checking this is going to be a pain.
> And making gobj injective immediately solves the problem.
>
> In the midtime, the problem is fixed in the git version of
> lablgtk2 by pretending that gobj is a private sum type (whose
> contents are abstract).
>
> This also empasizes that the new restriction does not impact
> only GADTs: all constrained type parameters are also concerned.
>
>         Jacques Garrigue
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

  reply	other threads:[~2013-05-04  7:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-28  0:02 Jacques Garrigue
2013-04-28  2:45 ` Markus Mottl
2013-04-28 10:28   ` Jacques Garrigue
2013-04-28  5:54 ` Jacques Le Normand
2013-04-29  3:45 ` Ivan Gotovchits
2013-04-29  4:03   ` Ivan Gotovchits
2013-04-29  5:17 ` Jacques Le Normand
2013-04-29  7:58   ` Alain Frisch
2013-04-29 10:52     ` Jacques Garrigue
2013-04-29 11:23       ` Alain Frisch
2013-04-29 16:37         ` Nathan Mishra Linger
2013-04-29 23:53           ` Jacques Garrigue
2013-04-30  5:45       ` Jacques Garrigue
2013-05-04  6:46         ` Jacques Garrigue
2013-05-04  7:09           ` Gabriel Scherer [this message]
2013-05-04 12:28             ` Jacques Garrigue
2013-04-30  6:59       ` Alain Frisch
2013-04-30  7:56         ` Jacques Garrigue
2013-04-30  8:02           ` Alain Frisch
2013-04-30  8:18             ` Jacques Garrigue
2013-04-30  9:11               ` Gabriel Scherer
2013-04-30  9:55                 ` Jacques Garrigue
2013-04-30 10:12                   ` Leo White
2013-04-30 11:30                     ` Gabriel Scherer
2013-04-30 13:06                       ` Leo White
2013-04-29  7:59   ` Gabriel Scherer
2013-07-01 14:47 ` Alain Frisch
2013-07-01 23:20   ` Jacques Garrigue
2013-07-03 16:08     ` Alain Frisch
2013-07-03 16:13       ` Gabriel Scherer
2013-07-04  6:07         ` [Caml-list] Request for feedback: A problem with injectivity oleg
2013-07-04  7:35           ` Alain Frisch
2013-07-05 10:30             ` oleg
2013-07-05 12:02               ` Alain Frisch
2013-07-04  1:00       ` [Caml-list] Request for feedback: A problem with injectivity and GADTs Jacques Garrigue
2013-07-04  8:14         ` Alain Frisch
2013-07-04  8:52           ` Jacques Garrigue

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='CAPFanBHo64JUMkpcx5D+yKNVLnbRuF1jCVZ0B8oE=1Li=fkq-g@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).