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 JAA02080; Tue, 28 Sep 2004 09:23:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 JAA01553 for ; Tue, 28 Sep 2004 09:23:15 +0200 (MET DST) Received: from will.iki.fi (will.iki.fi [217.169.64.20]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i8S7NEWb024449 for ; Tue, 28 Sep 2004 09:23:15 +0200 Received: from [10.0.20.56] (fa-3-0-0.fw.exomi.com [217.169.64.99]) by will.iki.fi (Postfix) with ESMTP id 59925201; Tue, 28 Sep 2004 10:23:14 +0300 (EEST) Message-ID: <4159114B.7030200@exomi.com> Date: Tue, 28 Sep 2004 10:22:51 +0300 From: Ville-Pertti Keinonen User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040828) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Danny Yoo Cc: "Rafael 'Dido' Sevilla" , John Goerzen , caml-list@inria.fr Subject: Re: [Caml-list] Observations on OCaml vs. Haskell References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41591162.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 observations:01 haskell:01 ocaml's:01 run-time:01 haskell:01 type-safe:01 fallback:01 val:01 val:01 ints:01 ocaml:01 overloading:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Danny Yoo wrote: >only ints. I think OCaml's arithmetic operators are monomophic to avoid >the cost of polymorphism. > > I'm fairly certain that type safety is a significant part of the reason; if they were polymorphic, they'd accept any kind of arguments, not just numbers. What's the product of two strings? A run-time type error? Haskell doesn't suffer from this because it has type classes. There are other type-safe ways to address the issue - SML uses overloading, with a fallback type of int for cases where the type of the expression can't be determined: - fun f x y = x + y; val f = fn : int -> int -> int - fun f (x : real) y = x + y; val f = fn : real -> real -> real ------------------- 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