caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Lukasz Stafiniak <lukstafi@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Polymorphic recursion and GADTs
Date: Tue, 10 Dec 2013 23:51:56 +0100	[thread overview]
Message-ID: <CAJMfKEWY2EUtpzLX8KWUMOK7=dGvGmNcDBwLZxERMa3MTNdoqA@mail.gmail.com> (raw)
In-Reply-To: <83E00BC5-3599-4702-873E-0FD6863050CC@math.nagoya-u.ac.jp>

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

On Tue, Dec 10, 2013 at 11:43 PM, Jacques Garrigue <
garrigue@math.nagoya-u.ac.jp> wrote:

>
> As always, Gabriel's answer is correct, but I have two remarks.
> First, concerning your first example where you needed annotations on the
> local function,
> you can actually avoid that by using pattern matching rather than function
> application:
>
> I realized that after posting :-)


>
> Now, for the above example, of course you don't need to annotate the
> "function" construct,
> but if you want to name the rigid variables 't47 and 't59, you can do that
> through eta-expansion:
>
> let rec eval : type a . (a term -> a) =
>   function Lit i -> i | IsZero x -> is_zero (eval x)
>     | Plus (x, y) -> plus (eval x) (eval y)
>     | If (b, t, e) -> if_then (eval b) (eval t) (eval e)
>     | Pair (x, y) -> (eval x, eval y)
>     | Fst p -> (fun (type b) p -> let ((x, y): (a * b)) = eval p in x) p
>     | Snd p -> (fun (type b) p -> let ((x, y): (b * a)) = eval p in y) p
>
> Not very clean, so we need to do something about it.
>
> I do not need it, I am just exploring ways of outputting that information
in case someone would find it useful (under the big conditional that
someone would find InvarGenT useful in the first place, rather than just
cool...)

[-- Attachment #2: Type: text/html, Size: 2010 bytes --]

  reply	other threads:[~2013-12-10 22:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 17:16 Lukasz Stafiniak
2013-12-09 17:24 ` Lukasz Stafiniak
2013-12-09 21:34   ` Lukasz Stafiniak
2013-12-10 13:20     ` Lukasz Stafiniak
2013-12-10 13:21       ` Lukasz Stafiniak
2013-12-10 14:24         ` Lukasz Stafiniak
2013-12-10 19:07           ` Gabriel Scherer
2013-12-10 22:43           ` Jacques Garrigue
2013-12-10 22:51             ` Lukasz Stafiniak [this message]
2013-12-10 22:55               ` Lukasz Stafiniak
2013-12-09 17:25 ` Gabriel Scherer

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='CAJMfKEWY2EUtpzLX8KWUMOK7=dGvGmNcDBwLZxERMa3MTNdoqA@mail.gmail.com' \
    --to=lukstafi@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).