Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Observations on OCaml vs. Haskell
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-09-28 (07:23)
From: Ville-Pertti Keinonen <will@e...>
Subject: Re: [Caml-list] Observations on OCaml vs. Haskell
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 Archives:
Bug reports: FAQ:
Beginner's list: