From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2N5CvcO009465 for ; Fri, 23 Mar 2012 06:12:57 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQCAMkFbE/RVdm2mGdsb2JhbABEphKROAgiAQEBAQEICQ0HFCeCCQEBAQQSAhMZARsSCwEDDAYFCwMKDSEiAREBBQEKEgYTCAoQh2gLmjEKjBaCcYUKP4h2AQULkHgElV+OST2ECg X-IronPort-AV: E=Sophos;i="4.73,633,1325458800"; d="scan'208";a="150826222" Received: from mail-lb0-f182.google.com ([209.85.217.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 23 Mar 2012 06:12:52 +0100 Received: by lboi15 with SMTP id i15so3864584lbo.27 for ; Thu, 22 Mar 2012 22:12:51 -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:content-transfer-encoding; bh=fvmnFbCGQScpAavUytv603KR4780FgeKjpPfFDFzScg=; b=KLJG7qyFKlkXfKS+CQWm/azu/E7nRte4bjd8INlJf5/UDwhkhnkgf5oe3QCPYviKjS Ewu5qcgYSyw6s5GKpb71VeVk8QPAhfE7QidGeqoIlfnCjvf0J0Kx0gvlriYMd50ItGQZ o8dOSa/UFt4I5hlDT7CqMp/1/FKznIrCYXXwnEDKGzMfRvgW6Rnst3LL61WL6b5Kl//r wBVAUd/4pTyF6WS1bB6ku2BMJp22vlelVLzq2WTwO1/xrZ+cPhG1cYZQnRBAtQvSsYSa jTXCjGFsR3uy7+3gMXuBeMqSK24cfyQZcxSblByxD3jrBafBkuJSb+CsFhc7bDVltN/C oaWw== Received: by 10.112.85.136 with SMTP id h8mr3906769lbz.72.1332479571147; Thu, 22 Mar 2012 22:12:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.130.233 with HTTP; Thu, 22 Mar 2012 22:12:10 -0700 (PDT) In-Reply-To: <20120323045817.GA26450@davidb.org> References: <20120323045817.GA26450@davidb.org> From: Gabriel Scherer Date: Fri, 23 Mar 2012 06:12:10 +0100 Message-ID: To: David Brown Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q2N5CvcO009465 Subject: Re: [Caml-list] Insufficient polymorphism in local let. This is a consequence of value restriction, with a direct workaround. See the FAQ: "A function obtained through partial application is not polymorphic enough" http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion let get1 a b = let must x = lmust "get2" x in .... On Fri, Mar 23, 2012 at 5:58 AM, David Brown wrote: > I'm trying to figure out how to get 'lmust' in 'get2' in the code > below to work.  It seems that it's type is being inferred as > >  string -> string option -> string > > instead of > >  string -> 'a option -> 'a > > The 'must' definition keeps it's polymorphism, as seen in 'get1'.  Is > there some way I can annotate the definition of 'lmust' so that it > will work?  Lifting 'lmust' out of 'get2' doesn't seem to help. > > Thanks, > David > > let must section name = function >  | Some o -> o >  | None ->     Printf.eprintf "Expecting %s in %s\n%!" name section; >    exit 1 > > type foo = { a: string; b: int } > > let get1 a b = >  { a = must "get1" "a" a; >    b = must "get1" "b" b } > > let get2 a b = >  (* This isn't polymorphic enough. *) >  let lmust = must "get2" in >  { a = lmust "a" a; >    b = lmust "b" b } > > -- > 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 >