caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: "Mário José Parreira Pereira" <mariojppereira@gmail.com>
Cc: Lukasz Stafiniak <lukstafi@gmail.com>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Type of term
Date: Thu, 6 Feb 2014 20:01:48 +0100	[thread overview]
Message-ID: <CAPFanBH+Ycw_G5EhE0pVH4ymdh77Ca4NGkXN5CeSjDNn9jo8xw@mail.gmail.com> (raw)
In-Reply-To: <52F3C710.4020500@gmail.com>

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

 No, there is not.

What are you trying to do?

On Thu, Feb 6, 2014 at 6:32 PM, Mário José Parreira Pereira
<mariojppereira@gmail.com> wrote:
> 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.
>
>

  parent reply	other threads:[~2014-02-06 19:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 17:17 Mário José Parreira Pereira
2014-02-06 17:17 ` Lukasz Stafiniak
2014-02-06 17:32   ` Mário José Parreira Pereira
2014-02-06 17:45     ` Raphaël Proust
2014-02-06 19:01     ` Gabriel Scherer [this message]
2014-02-06 19:05       ` Simon Cruanes
2014-02-10  8:58     ` Goswin von Brederlow
2014-02-06 17:23 ` Lukasz Stafiniak

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=CAPFanBH+Ycw_G5EhE0pVH4ymdh77Ca4NGkXN5CeSjDNn9jo8xw@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=lukstafi@gmail.com \
    --cc=mariojppereira@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).