Re: convincing management to switch to Ocaml

From: John Prevost (prevost@maya.com)
Date: Tue Aug 31 1999 - 08:35:03 MET DST


To: John Skaller <skaller@maxtal.com.au>
Subject: Re: convincing management to switch to Ocaml
From: John Prevost <prevost@maya.com>
Date: 31 Aug 1999 02:35:03 -0400
In-Reply-To: John Skaller's message of "Tue, 31 Aug 1999 15:19:48 +1000"

John Skaller <skaller@maxtal.com.au> 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.



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:25 MET