From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id C9F90BC69 for ; Fri, 19 Jan 2007 13:03:51 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0JC3p6d016342 for ; Fri, 19 Jan 2007 13:03:51 +0100 Received: by ug-out-1314.google.com with SMTP id q2so479995uge for ; Fri, 19 Jan 2007 04:03:51 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=BFAtHl1F86XNCpePx90dczeQMuFxhLqIZF/shprzpo4Jlg2DFFEvqcB0Ow3goRRA09ySiQh0ExczYevtEdDm13u9Lwjvbq2wTAlN6+P7SgySII2Q8BwZi9j0BqvsfobF7tNhFDIfKARHXAkbqAvfUFiGSm9ilrjF2M0Jge59o6Y= Received: by 10.82.105.13 with SMTP id d13mr490838buc.1169208230583; Fri, 19 Jan 2007 04:03:50 -0800 (PST) Received: by 10.82.100.16 with HTTP; Fri, 19 Jan 2007 04:03:50 -0800 (PST) Message-ID: Date: Fri, 19 Jan 2007 13:03:50 +0100 From: Tom To: caml-list@yquem.inria.fr Subject: Re: Fwd: [Caml-list] Polymorphic Variants In-Reply-To: <20070119111429.GA4822@feanor> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_203201_26635464.1169208230399" References: <200701182114.10133.jon@ffconsultancy.com> <20070119092648.GA3604@feanor> <20070119111429.GA4822@feanor> X-j-chkmail-Score: MSGID : 45B0B3A7.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45B0B3A7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 0100,:01 overloading:01 haskell's:01 overloading:01 infix:01 run-time:01 compile-time:01 inference:01 inference:01 haskell:01 compiler:01 overload:01 haskell's:01 haskell:01 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_203201_26635464.1169208230399 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 19/01/07, Dirk Thierbach wrote: > > [Please don't reply directly to me AND to the list, just to the list > is enough. Thanks.] Sorry... didn't mean to... I mean, I didn't know there's a problem. I don't get mail that's sent to me AND the caml-list twice... On Fri, Jan 19, 2007 at 11:35:36AM +0100, Tom wrote: > > On 19/01/07, Dirk Thierbach wrote: > > > Well, in some sense, generic value overloading is somewhat like > Haskell's > > type classes, > > Yes. That's exactly what type classes are for -- overloading of functions > (including infix operators). No, no, you misunderstood me. Type-classes are run-time dispatched. What I want is static/compile-time overloading. I meant they are similar for the type inference system. My type system should use roughly the same algorithm for inference that Haskell uses, but it should infer the typeclasses (the possible types a type variable can be instantiated) automatically. Actually, I don't even want such types be extensible - one function will always have either ONE input type (int -> int), or ANY input types ('a -> 'a), but two such functions might have the same NAME. The compiler's task isn't to supply all possible implementations of some mathematical function - that's the programmers task: if I define let negate a = - a it will not have all possible types (int, float, complex, ...) but only one of them. For another type, I have to define it again: let negate a = - a I can also specify types: let negate a : complex = - a (and of course ask the compiler to do it for me: overload let negate a = - a but that's only a shortcut - internally, it would be expanded into n functions, each ranging over one of n types. ) My overloading would be more C++ / C# / Java-like - but the inference technique should be similar to Haskell's. And that's exactly what the Haskell compiler does (see below). BTW, > the important thing is the type variable after the predicate, just > ignore the forall's for the moment. So the above type is nonsense, a > possible example type could look like: Sorry, I don't know Haskell that well. But you know what I meant :) > > Can Haskell overload values? And functions by their return type? > > It can overload integer and fixed point literals (in the way described > above). It cannot overload any other "values" (whatever that should > be :-). By overloading values, I mean: let null = 0 let null = false if null then 1 else null - Tom ------=_Part_203201_26635464.1169208230399 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 19/01/07, Dirk Thierbach <dthierbach@gmx.de> wrote:
[Please don't reply directly to me AND to the list, just to the list
is enough. Thanks.]
 
Sorry... didn't mean to... I mean, I didn't know there's a problem. I don't get mail that's sent to me AND the caml-list twice...

On Fri, Jan 19, 2007 at 11:35:36AM +0100, Tom wrote:
> On 19/01/07, Dirk Thierbach < dthierbach@gmx.de> wrote:

> Well, in some sense, generic value overloading is somewhat like Haskell's
> type classes,

Yes. That's exactly what type classes are for -- overloading of functions
(including infix operators).
 
No, no, you misunderstood me. Type-classes are run-time dispatched. What I want is static/compile-time overloading. I meant they are similar for the type inference system. My type system should use roughly the same algorithm for inference that Haskell uses, but it should infer the typeclasses (the possible types a type variable can be instantiated) automatically.
 
Actually, I don't even want such types be extensible - one function will always have either ONE input type (int -> int), or ANY input types ('a -> 'a), but two such functions might have the same NAME. The compiler's task isn't to supply all possible implementations of some mathematical function - that's the programmers task:
 
if I define
  let negate a = - a
it will not have all possible types (int, float, complex, ...) but only one of them. For another type, I have to define it again:
  let negate a = - a
I can also specify types:
  let negate a : complex = - a
(and of course ask the compiler to do it for me:
  overload let negate a = - a
but that's only a shortcut - internally, it would be expanded into n functions, each ranging over one of n types. )
 
My overloading would be more C++ / C# / Java-like - but the inference technique should be similar to Haskell's.

And that's exactly what the Haskell compiler does (see below).
 
 

BTW,
the important thing is the type variable after the predicate, just
ignore the forall's for the moment. So the above type is nonsense, a
possible example type could look like:
 
Sorry, I don't know Haskell that well. But you know what I meant :)


> Can Haskell overload values? And functions by their return type?

It can overload integer and fixed point literals (in the way described
above). It cannot overload any other "values" (whatever that should
be :-).
 
By overloading values, I mean:
 
let null = 0
let null = false
 
if null then 1 else null
 
- Tom
------=_Part_203201_26635464.1169208230399--