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 VAA08749; Mon, 27 Sep 2004 21:08:57 +0200 (MET DST) 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 VAA12822 for ; Mon, 27 Sep 2004 21:08:55 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from gatekeeper.elmer.external.excelhustler.com (gatekeeper.excelhustler.com [68.99.114.105]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8RJ8sJX025728 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=FAIL) for ; Mon, 27 Sep 2004 21:08:55 +0200 Received: from chatterbox.elmer.internal.excelhustler.com (unknown [192.168.0.12]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "chatterbox.elmer.internal.excelhustler.com", Issuer "excelhustler.com" (not verified)) by gatekeeper.elmer.external.excelhustler.com (Postfix) with ESMTP id 4E360F2143; Mon, 27 Sep 2004 14:08:53 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id 27036F204F; Mon, 27 Sep 2004 14:08:53 -0500 (CDT) Received: from chatterbox.elmer.internal.excelhustler.com ([192.168.0.12]) by localhost (chatterbox [192.168.0.12]) (amavisd-new, port 10025) with ESMTP id 31588-01; Mon, 27 Sep 2004 14:08:51 -0500 (CDT) Received: from wile.internal.excelhustler.com (wile.internal.excelhustler.com [192.168.1.34]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id D16E34EDAB; Mon, 27 Sep 2004 14:08:51 -0500 (CDT) Received: by wile.internal.excelhustler.com (Postfix, from userid 1000) id 065392D001; Mon, 27 Sep 2004 14:08:52 -0500 (CDT) From: John Goerzen To: caml-list@inria.fr Subject: [Caml-list] Observations on OCaml vs. Haskell Date: Mon, 27 Sep 2004 14:08:51 -0500 User-Agent: KMail/1.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409271408.51872.jgoerzen@complete.org> X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at excelhustler.com X-Miltered: at concorde with ID 41586546.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; observations:01 haskell:01 haskell:01 glance:01 re-use:01 haskell's:01 32,:01 ocaml's:01 ocaml:01 ocaml:01 int:01 int:01 arithmetic:01 ought:01 lazy:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I recently decided I ought to learn a bit about Haskell. I've done so, and while it is remarkably similar to OCaml in many ways, there are a few things I really like about Haskell. At first glance, to this relative latecomer to both languages, the Haskell approach to these things looks very appealing. I am wondering if you know of drawbacks of their approach, and why the OCaml designers opted for something different. 1. Haskell lists resemble OCaml Streams This is, in fact, one of my main complaints about OCaml lists: that they are a distinct type from OCaml streams. Streams have a lot of power, and having to convert back and forth between the two doesn't always make a lot of sense. I've doing things like written versions of map or filter for streams, making them lazy, which results in a very powerful approach to things like file reading, etc. It's annoying to not be able to re-use all the existing list-related functions on streams. In Haskell, there is no separate stream type; a list is a stream. 2. Haskell strings are lists of characters It's annoying that strings aren't normally processed this way in OCaml, and even more annoying that (^) or (::) cannot be used in pattern matching over strings. I like Haskell's approach. The list concatenation operator is the same as the string concatenation operator in Haskell. 3. The Num typeclass I've written several functions that can work with a "number-like" type. I don't really care if I get an integer, Int32, Int64, float, or what. But since these are all different types in OCaml, I am forced to care, right down to using +, +., or Int64.add to perform basic arithmetic. The Num typeclass in Haskell neatly solves that whole problem; I could take a Num, use a unified set of operators, and produce the appropriate result. For #1 and #2, the only reasons I can think of for OCaml's approach involve performance. For #3, I can't really come up with any good reason, since one can always specify a type of Int or whatever in Haskell anyway. OCaml enlightenment appreciated :-) Thanks, John ------------------- 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