caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Observations on OCaml vs. Haskell
@ 2004-09-27 19:08 John Goerzen
  2004-09-27 20:24 ` Rafael 'Dido' Sevilla
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: John Goerzen @ 2004-09-27 19:08 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2004-09-29 15:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-27 19:08 [Caml-list] Observations on OCaml vs. Haskell John Goerzen
2004-09-27 20:24 ` Rafael 'Dido' Sevilla
2004-09-27 21:34   ` Danny Yoo
2004-09-28  7:22     ` Ville-Pertti Keinonen
2004-09-28 18:02       ` Jon Harrop
2004-09-29 14:26         ` Brian Hurt
2004-09-29 14:20           ` Jon Harrop
2004-09-29 15:03           ` Dmitry Lomov
2004-09-28 10:10     ` [Caml-list] Caml monomorphisation (was Observations on OCaml vs. Haskell) Diego Olivier Fernandez Pons
2004-09-28 12:01       ` Richard Jones
2004-09-28 17:50       ` Jon Harrop
2004-09-28  1:56   ` [Caml-list] Observations on OCaml vs. Haskell skaller
2004-09-28  9:31   ` Keith Wansbrough
2004-09-28  9:55     ` Rafael 'Dido' Sevilla
2004-09-27 21:11 ` Christophe TROESTLER
2004-09-28  1:32 ` Jacques GARRIGUE
2004-09-28  1:46 ` skaller
2004-09-28  8:27 ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).