caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jiten Pathy <jpathy@fssrv.net>
To: Jeremy Yallop <yallop@gmail.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] phantom type
Date: Mon, 27 Apr 2015 04:32:25 -0700	[thread overview]
Message-ID: <CAL2Z3DCMafiD11vrVA+gZ4W2yGxTLz_CQgfQbaVs2VsoX3D4+A@mail.gmail.com> (raw)
In-Reply-To: <CAAxsn=GiUeB17MWJVaLcu-=2E2kzP3R2cmdHR_BiEPb1Q1gu+g@mail.gmail.com>

Thanks for the reference.

On Mon, Apr 27, 2015 at 3:36 AM, Jeremy Yallop <yallop@gmail.com> wrote:
> On 27 April 2015 at 11:23, Jiten Pathy <jpathy@fssrv.net> wrote:
>> Trying to use phantom types instead of gadt for well-constructed term
>> example. Is it possible to define an evaluator eval : 'a term -> 'a
>> using phantom types?
>
> No, it's not really possible.  If the 'a parameter to 'term' is
> phantom then 'term' is defined using some other unparameterised type
> such as your 'expr':
>
>> type expr = Zero | Succ of expr | Iszero of expr;;
>
> and the problem comes down to writing a function of type
>
>    expr -> 'a
>
> which is clearly impossible.
>
> Phantom types only really help with constraints on building or
> transforming values, not with deconstructing them.
>
> However, there are various ways of writing well-typed evaluators
> without using GADTs, e.g.using a "final" encoding, which represents a
> term as an evaluation function:
>
>    Finally Tagless, Partially Evaluated:
>    http://okmij.org/ftp/tagless-final/JFP.pdf
>
> or by encoding GADTs using polymorphism:
>
>    First-class modules: hidden power and tantalizing promises
>    http://okmij.org/ftp/ML/first-class-modules/first-class-modules.pdf
>
> Jeremy.

  reply	other threads:[~2015-04-27 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 10:23 Jiten Pathy
2015-04-27 10:36 ` Jeremy Yallop
2015-04-27 11:32   ` Jiten Pathy [this message]
2015-04-27 11:51   ` Stephen Dolan
2015-04-27 12:17     ` Jiten Pathy
2015-04-27 12:30       ` Jeremy Yallop
2015-04-28  4:35         ` Jiten Pathy

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=CAL2Z3DCMafiD11vrVA+gZ4W2yGxTLz_CQgfQbaVs2VsoX3D4+A@mail.gmail.com \
    --to=jpathy@fssrv.net \
    --cc=caml-list@inria.fr \
    --cc=yallop@gmail.com \
    /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).