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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 375997ED7A for ; Thu, 6 Sep 2012 11:56:15 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.210.182 as permitted sender) identity=mailfrom; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-iy0-f182.google.com) identity=helo; client-ip=209.85.210.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-iy0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0CAP9xSFDRVdK2m2dsb2JhbABFqT6RWQgiAQEBAQEICQsJFCeCIAEBAQQSAhMZARsSCwEDDAYFCwMKDSEiAREBBQEKEgYTEhCHWwEDDAucBwkDjCOCc4UWChknAwIIWYh0AQUMiwUahisDlVmBFI0oPoQFgV8 X-IronPort-AV: E=Sophos;i="4.80,379,1344204000"; d="scan'208";a="154865994" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Sep 2012 11:56:14 +0200 Received: by iayy25 with SMTP id y25so3199151iay.27 for ; Thu, 06 Sep 2012 02:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=O+lQyqut1p101z5ZS3Y1nKBCdM9tSR9wcdf39/JFcFk=; b=lNQEMo/qFDxv/4i8FZzAQW4/YLmj2pdt/RHZvmfdIRE+sl/hHEMu+1TydTmRS1fxb1 X0TD3iWoH2rchSPNYhh/x6+9gzfRasGery+8BU5+D0UVTZ5qfWgXUTxyWIQn4l4mMu2n CFg3g40PuzksxlP34Z+edS8GH7W/fvs9H7tXoCzt/GbuOdM9bRyi0xEMLhJL9e0nO737 ODrd49EKHasndxRL4HtlqR+35jfg09fTDve4/fNEZuzONhYcrANPtT/AuiMW0HbNU/tj LYZth6bkJytcgGXkI3hwZzSYg9Gu66qtZZg48XV5Y6MtwmT1mkyxPyj4pTP0Vid9vkGw aiyw== Received: by 10.42.157.5 with SMTP id b5mr1521049icx.37.1346925372890; Thu, 06 Sep 2012 02:56:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.32.39 with HTTP; Thu, 6 Sep 2012 02:55:32 -0700 (PDT) In-Reply-To: References: <1346923259.77614.YahooMailRC@web180012.mail.gq1.yahoo.com> From: Gabriel Scherer Date: Thu, 6 Sep 2012 11:55:32 +0200 Message-ID: To: Philippe Wang Cc: Dan Bensen , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] polymorphic parameters Philippe, the function parameter is not really polymorphic in your example: it's the whole function type that is. `f` is given the type (('a -> 'b) -> 'a -> 'b) by the OCaml type-checker, but this is syntactic sugar for (forall 'a 'b. ('a -> 'b) -> 'a -> 'b). Note how the universal quantifiers are at the beginning of the type, and not inside the function parameter. One could expect to be able to express the type forall 'a . (forall 'b . 'a -> 'b) -> 'a -> int for example. See the following FAQ item for a short answer to this question: http://caml.inria.fr/resources/doc/faq/core.en.html#polymorphic-arguments On Thu, Sep 6, 2012 at 11:35 AM, Philippe Wang wrote: > On Thu, Sep 6, 2012 at 11:20 AM, Dan Bensen wrote: >> How do you indicate that a function parameter is a polymorphic function? > > I hope these 2 lines will answer your question: > > let f g x = g x > > let f (g: 'a -> 'b) x = g x > > -- > Philippe Wang > mail@philippewang.info > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >