English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 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