caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: rixed@happyleptic.org
To: "Ivan Gotovchits" <ivg@ieee.org>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Calling a single function on every member of a GADT?
Date: Wed, 08 Jan 2020 07:54:22 +0100	[thread overview]
Message-ID: <41592816-f82e-43a4-b67f-02e69623fe23@www.fastmail.com> (raw)
In-Reply-To: <CALdWJ+yTGigM=jjhnuk6VNOg+0Reo5UneJyVFWna5LG=3VMk2Q@mail.gmail.com>

Hello and thank you for the answer.

On Tue, Jan 7, 2020, at 21:21, Ivan Gotovchits wrote:
> It is the limitation of the let-bound polymorphism. (...)
> In your case, I would define a visitor type, e.g.,
>  type 'r visitor = {visit : 'a. 'a term -> 'r -> 'r}

Oh I see. I've used this trick to force a function to be polymorphic, but I failed to see that this was the problem because to me `f` is not any more polymorphic when the `term` is a GADT than when it's not.

So there is no lighter syntax to specify that `f` should accept any member of a GADT than the syntax to specify that `f` should accept any type at all?

I wonder, is this just a limitation of the OCaml parser or is there some deep reason for these work-around (like is the case, from my understanding, for the value restriction)?

Sorry for asking such simple questions but I've build a mental model of how OCaml type checking works mostly from trials and errors, which used to work great until some versions ago :) 

  reply	other threads:[~2020-01-08  6:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 19:24 rixed
2020-01-07 20:21 ` Ivan Gotovchits
2020-01-08  6:54   ` rixed [this message]
2020-01-08  9:43     ` Jacques Garrigue
2020-01-08 20:32     ` Ivan Gotovchits
2020-01-10  9:49       ` Malcolm Matalka
2020-01-10 19:52         ` Ivan Gotovchits

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=41592816-f82e-43a4-b67f-02e69623fe23@www.fastmail.com \
    --to=rixed@happyleptic.org \
    --cc=caml-list@inria.fr \
    --cc=ivg@ieee.org \
    /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).