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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 873D67EE34 for ; Thu, 31 Mar 2016 14:06:39 +0200 (CEST) IronPort-PHdr: 9a23:Qz0QphEjAC24K4nZsxeHFp1GYnF86YWxBRYc798ds5kLTJ75o8iwAkXT6L1XgUPTWs2DsrQf27qQ6PirAjVIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/nh6bpo9aIOk1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv/hpCvqhOvxkBfwFVHV1e1wyscbisB2GSQqU+lMdVH8Xm1xGGVvr9hb/C6jwti/7v+81jDPcZuXyTLo5Qyiz9LpxRlnmknFUZHYC7GjLh5ko3+pgqxW7qkkim4M= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=r.3@libertysurf.fr; spf=None smtp.mailfrom=r.3@libertysurf.fr; spf=None smtp.helo=postmaster@smtp2-g21.free.fr Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of r.3@libertysurf.fr) identity=pra; client-ip=212.27.42.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.3@libertysurf.fr"; x-sender="r.3@libertysurf.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of r.3@libertysurf.fr) identity=mailfrom; client-ip=212.27.42.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.3@libertysurf.fr"; x-sender="r.3@libertysurf.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp2-g21.free.fr) identity=helo; client-ip=212.27.42.2; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="r.3@libertysurf.fr"; x-sender="postmaster@smtp2-g21.free.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ARAQB/Ef1WkgIqG9RdhAd9pwsGgVeUKxmHMzwQAQEBAQEBAQERAQEBAQcLCwkhL4Itgj4EEXYCBSECEQJAGQgCiCMEoQyPXZFJfIRaihiCNIJWBZdyghSDX4pJdoYOhVWPFTeBYQEBAQcBAQEBAQE+EQiBTGqIbQEBAQ X-IPAS-Result: A0ARAQB/Ef1WkgIqG9RdhAd9pwsGgVeUKxmHMzwQAQEBAQEBAQERAQEBAQcLCwkhL4Itgj4EEXYCBSECEQJAGQgCiCMEoQyPXZFJfIRaihiCNIJWBZdyghSDX4pJdoYOhVWPFTeBYQEBAQcBAQEBAQE+EQiBTGqIbQEBAQ X-IronPort-AV: E=Sophos;i="5.24,422,1454972400"; d="scan'208";a="211369865" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 31 Mar 2016 14:06:39 +0200 Received: from [172.16.79.17] (unknown [143.196.127.2]) (Authenticated sender: r.3) by smtp2-g21.free.fr (Postfix) with ESMTPSA id D7E114B01B1 for ; Thu, 31 Mar 2016 14:01:43 +0200 (CEST) From: William To: caml-list@inria.fr Message-ID: <56FD12CC.20509@libertysurf.fr> Date: Thu, 31 Mar 2016 14:06:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] explicit polymorphic type annotation Hi, I don't know how to handle this, and can not find how to do it in the manual. I would like "func" to be polymorphic : let f func = Printf.printf "%i\n%!" (func (1,2)); Printf.printf "%f\n%!" (func (1.,2.));; f fst;; f snd;; => Characters 85-87: Printf.printf "%f\n%!" (func (1.,2.));; ^^ Error: This expression has type float but an expression was expected of type int let f (func:('a. 'a * 'a -> 'a)) = Printf.printf "%i\n%!" (func (1,2)); Printf.printf "%f\n%!" (func (1.,2.));; f fst;; f snd;; => Characters 15-16: let f (func:('a. 'a * 'a -> 'a)) = ^ Error: Syntax error: type expected. Could someone show me how to handle this ? Also, I did not find any relevant chapter in ocaml.org or ocaml reference manual to explain how to do. Any pointers ? Best regards