From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA04654 for caml-redistribution; Tue, 31 Aug 1999 19:15:35 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA07813 for ; Tue, 31 Aug 1999 08:33:31 +0200 (MET DST) Received: from isil.maya.com (HOPKINS.PC.CS.CMU.EDU [128.2.215.35]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id IAA18973; Tue, 31 Aug 1999 08:33:28 +0200 (MET DST) Received: (from prevost@localhost) by isil.maya.com (8.9.3/8.9.3) id CAA29234; Tue, 31 Aug 1999 02:35:03 -0400 Sender: weis To: John Skaller Cc: Pierre Weis , caml-list@inria.fr Subject: Re: convincing management to switch to Ocaml References: <199908300802.KAA15269@pauillac.inria.fr> <3.0.6.32.19990831151948.00971280@mail.triode.net.au> From: John Prevost Date: 31 Aug 1999 02:35:03 -0400 In-Reply-To: John Skaller's message of "Tue, 31 Aug 1999 15:19:48 +1000" Message-ID: User-Agent: Gnus/5.070095 (Pterodactyl Gnus v0.95) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii John Skaller writes: > but the latter doesn't work right if I need the parameters > to have names. I tried: > > let (f: t2 -> t2 -> t3) x y = something;; > > and that doesn't seem to work? This shape is important, > where I have a set of functions of the same type, > with an abbreviation. There seems to be a problem, > that the operator -> is overloaded in meaning: > it means 'returns the type' and also 'has the value'. Hmm. I guess this is sort of a bit odd--it would make sense for the above to work, in terms of how type constraints usually work. (Maybe this ought to be changed to be more consistent.) If you need a workaround, however, the following *will* work: let (f : t2 -> t2 -> t3) = fun x y -> something likewise, the following (which doesn't put the types up front) will work: let f = (fun x y -> something : t2 -> t2 -> t3) Basically, the "reduced form" of let for functions, namely "let f x y = var" won't allow you to specify the type of the function as a whole, only the types of the arguments and the type of the result: let f (x : t2) (y : t2) = (something : t3) In some ways, this isn't really a problem--one of the big pieces of utility in the ML family of languages is that type inference allows you to leave out such type signatures. And explicit signatures for modules takes care of the general case. So, it's sort of an obscure problem. John.