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.