English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] OCaml popularity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sebastien Carlier <sebc@w...>
Subject: Re: [Caml-list] Re: Haskell-like syntax

brogoff@speakeasy.net writes:

> If you are really desparate to be able to do this kind of thing, that is, to 
> write your programs in a top down fashion, you can do it right now in OCaml, 
> sans CamlP4, by writing code like 
> 
>     let rec main () = 
>        let foo_arg = foo_aux () in 
>         foo foo_arg 
>     and foo = ... 
>     and foo_aux = ...

This is different: "let rec" doesn't give you polymorphism in OCaml.
The following code doesn't pass the type checker because the type of
"id" is not generalized:

let rec main () =
    print_string (id ""); print_int (id 0)
and id = fun x -> x;;

In Haskell, "where" generalizes - the following similar code is
accepted by Haskell compilers:

main =
    do putStr (id "")
       print (id 0)
    where id = \ x -> x

-- 
Sebastien

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