From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA07981; Thu, 25 Mar 2004 20:44:18 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA07917 for ; Thu, 25 Mar 2004 20:44:16 +0100 (MET) From: fis@wiwi.hu-berlin.de Received: from miro.wiwi.hu-berlin.de (miro.wiwi.hu-berlin.de [141.20.103.80]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2PJiFHd023161 for ; Thu, 25 Mar 2004 20:44:15 +0100 Received: from mini (miro [141.20.103.80]) by miro.wiwi.hu-berlin.de (8.11.7+Sun/8.8.6) with ESMTP id i2PJiEB22672 for ; Thu, 25 Mar 2004 20:44:14 +0100 (MET) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16483.13886.930859.583419@gargle.gargle.HOWL> Date: Thu, 25 Mar 2004 20:42:54 +0100 To: caml-list@inria.fr Subject: [Caml-list] type annotations for function values X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; annotations:01 narrowing:01 annotations:01 inelegant:01 matthias:01 ocaml:01 int:01 int:01 exists:01 float:02 float:02 explicit:03 horribly:04 let:04 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Keywords: X-UID: 362 hi all, as the grammar and type system of ocaml are so sophisticated, i am often having trouble narrowing down the source of an error message. the answer are of course type annotations, "i know this function here must have this type, trust me", something of that ilk. now this is easy: let f (x : float) (y : float) = 3 in 4;; but what do i do if i want to write down an explicit type for f? the only thing i found that works is let f : (float -> float -> int) = (fun x y -> 3) in 4;; which is horribly inelegant. why can't i do something like this? let (f : (float -> float -> int)) x y = 3 in 4;; let ((f x y) : (float -> float -> int)) = 3 in 4;; let ((f (x : float) (y : float)) : int) = 3 in 4;; the last one seems wrong, but anyway, i am still hoping that something like this exists. thanks, matthias ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners