From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 B936D7F7C2 for ; Thu, 6 Feb 2014 18:25:13 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mariojppereira@gmail.com) identity=pra; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mariojppereira@gmail.com"; x-sender="mariojppereira@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of mariojppereira@gmail.com designates 209.85.212.172 as permitted sender) identity=mailfrom; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mariojppereira@gmail.com"; x-sender="mariojppereira@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-wi0-f172.google.com) identity=helo; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mariojppereira@gmail.com"; x-sender="postmaster@mail-wi0-f172.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AikCAA3F81LRVdSslGdsb2JhbABZg0SJNbYTgQsWDgEBAQEHCwsJEiqCJQEBBScZARscAQEDDAYFBAcDCgkWCAcJAwIBAgEPAhEBBQELEQYNAQUCAQGHbAEDEQQBCKA2jF6DCZNcChknDWSIBhEBBQyMWIIWB4Q4BJY/gWyBMoUWhhaDVkGEWQ X-IPAS-Result: AikCAA3F81LRVdSslGdsb2JhbABZg0SJNbYTgQsWDgEBAQEHCwsJEiqCJQEBBScZARscAQEDDAYFBAcDCgkWCAcJAwIBAgEPAhEBBQELEQYNAQUCAQGHbAEDEQQBCKA2jF6DCZNcChknDWSIBhEBBQyMWIIWB4Q4BJY/gWyBMoUWhhaDVkGEWQ X-IronPort-AV: E=Sophos;i="4.95,793,1384297200"; d="scan'208,217";a="48068806" Received: from mail-wi0-f172.google.com ([209.85.212.172]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Feb 2014 18:25:13 +0100 Received: by mail-wi0-f172.google.com with SMTP id e4so39510wiv.17 for ; Thu, 06 Feb 2014 09:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=qy9JjgPHLSiBQ5Sf6ta/6hr5jPA6XtfLGu4P4n7sEIU=; b=w7SAfwfc5Iba7XzO4+e+Nt9zzwfK2pHxsxLxMzXl+ryDT8F2Lwk2k8EYnKF8Wke1k0 /sMu3xbt+fX/95LHMLT/R5Pm6OdROn4NnxPffdca9h9xTdkrgBRBRqftkZXqKeDzPNYc CfwvBxUrQ2tYh/WlQTnSw6roDF3XLyv/GwhfySIQ/G4KLc1nCpGOHRqAJHDsyNOdcQ8E cQhTbBkFgfAKUtekkRDB7T2IYsqpjJWDvcNadsze3SISiWnEddUN+77TAo4Kh/TcZsEY 264NI2H8DTOTE5gwBCLZelLyjj1dEQ0e/wJLWFLytMle0k8EXOgwpZyMmWj9UPpJCPfF LcbA== X-Received: by 10.180.100.70 with SMTP id ew6mr215627wib.57.1391707513060; Thu, 06 Feb 2014 09:25:13 -0800 (PST) Received: from [192.168.229.147] ([193.136.24.133]) by mx.google.com with ESMTPSA id y18sm354137wie.11.2014.02.06.09.25.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Feb 2014 09:25:12 -0800 (PST) Message-ID: <52F3C710.4020500@gmail.com> Date: Thu, 06 Feb 2014 17:32:00 +0000 From: "=?ISO-8859-1?Q?M=E1rio_Jos=E9_Parreira_Pereira?=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Lukasz Stafiniak CC: "caml-list@inria.fr" References: <52F3C3A1.8060500@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000401010309000706080709" X-Validation-by: mariojppereira@gmail.com Subject: Re: [Caml-list] Type of term This is a multi-part message in MIME format. --------------000401010309000706080709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi Lukasz, Thank you for your answer but I really can't see how GADTs can help me. I was just simply wandering if there wasn't any OCaml function that would work like: type_of(let f x = x) = 'a->'a There is, something that would compute exactly the same outcome as the Damas-Milner algorithm W. Bests, Mário Em 06-02-2014 17:17, Lukasz Stafiniak escreveu: > On Thu, Feb 6, 2014 at 6:17 PM, Mário José Parreira Pereira > > wrote: > > Hi all, > > Is there any way to get the type of (part of) a program? Something > like: > type_of(M) = sigma > computing the type of program M as sigma so I can pattern match it. > > > No. However, if you really need this rather than being confused by > programming patterns from Java / C# / C++, you should learn about > GADTs. > http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.html#toc85 > > Cheers. --------------000401010309000706080709 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Lukasz,

Thank you for your answer but I really can't see how GADTs can help me.

I was just simply wandering if there wasn't any OCaml function that would work like:
   type_of(let f x = x) = 'a->'a

There is, something that would compute exactly the same outcome as the Damas-Milner algorithm W.

Bests,
Mário

Em 06-02-2014 17:17, Lukasz Stafiniak escreveu:
On Thu, Feb 6, 2014 at 6:17 PM, Mário José Parreira Pereira <mariojppereira@gmail.com> wrote:
Hi all,

Is there any way to get the type of (part of) a program? Something like:
   type_of(M) = sigma
computing the type of program M as sigma so I can pattern match it.

No. However, if you really need this rather than being confused by programming patterns from Java / C# / C++, you should learn about GADTs. http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.html#toc85 

Cheers.

--------------000401010309000706080709--