From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 00C457FD08 for ; Mon, 27 Apr 2015 12:36:47 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=209.85.216.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 209.85.216.178 as permitted sender) identity=mailfrom; client-ip=209.85.216.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qc0-f178.google.com) identity=helo; client-ip=209.85.216.178; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-qc0-f178.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AyAgApED5VlLLYVdFcg19cBYMVxHyGBAKBJwc7EQEBAQEBAQERAQEBAQcLCwkfMIQgAQEBAgEBEhEEGQEbHQEDAQsGBQsDCgICJgICIgERAQUBHAYTIod0AQMJCA2lJz4xizmBa4J2iFsKGScNVYRsAQEBAQYBAQEBGAEFDoETiheCa4FLTweCaIFFBY8zhiOGOIEiPZAyggYSI4EMCYQYPTGCRAEBAQ X-IPAS-Result: A0AyAgApED5VlLLYVdFcg19cBYMVxHyGBAKBJwc7EQEBAQEBAQERAQEBAQcLCwkfMIQgAQEBAgEBEhEEGQEbHQEDAQsGBQsDCgICJgICIgERAQUBHAYTIod0AQMJCA2lJz4xizmBa4J2iFsKGScNVYRsAQEBAQYBAQEBGAEFDoETiheCa4FLTweCaIFFBY8zhiOGOIEiPZAyggYSI4EMCYQYPTGCRAEBAQ X-IronPort-AV: E=Sophos;i="5.11,656,1422918000"; d="scan'208";a="113653223" Received: from mail-qc0-f178.google.com ([209.85.216.178]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Apr 2015 12:36:47 +0200 Received: by qcyk17 with SMTP id k17so52809220qcy.1 for ; Mon, 27 Apr 2015 03:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3TogEwAGhKuJnp9+U1uE9cVfzYHG/3NkZBijrSxjB3c=; b=Z8NRNFF3Z2zbkY1lspyA8HuntvcaVFkrzBG7xRSeqqTbJf5RKZZ9zbQ3gQcO0KzyZJ 6+a/5NOSMeNGmuI0cSvsPaOTVYJ/o1xCCGCWp20h6dLiDp1AWcp7raFfBnezgvkNAqWK Vllv6bWrlhqx2NqYD1mEHxdFvIDsSa83dBQeo8OT4IaNmwNpa35g96Rho7sYc/JAB3Er LxzZpR4WW8kqYc6uGUdGHIlOVDHKRLPZeS8V9kkNxsmfzXFdjT+h31Ud/Hjve7PvYUpv ItTv759RTXbr5OUHnOu4QH3w2hvuQEJdonPHdmAQivuYr2R66JCacvP/zlbm6gYkdPDe N4qQ== MIME-Version: 1.0 X-Received: by 10.140.98.208 with SMTP id o74mr7026157qge.66.1430131005828; Mon, 27 Apr 2015 03:36:45 -0700 (PDT) Received: by 10.229.40.7 with HTTP; Mon, 27 Apr 2015 03:36:45 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Apr 2015 11:36:45 +0100 Message-ID: From: Jeremy Yallop To: Jiten Pathy Cc: "caml-list@inria.fr" Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] phantom type On 27 April 2015 at 11:23, Jiten Pathy 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.