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] Why must types be always defined at the top level?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-06-24 (23:20)
From: Brian Hurt <bhurt@s...>
Subject: RE: [Caml-list] Why must types be always defined at the top level?
On Thu, 24 Jun 2004, John Hughes wrote:

> I have one more question, though: 
> 5. Why can I no longer type-annotate things I've written, so that
> let f x y z = (x = y) & (y = z)
> defines a function applicable to ALL types? I actually *liked*
> being able to say something like
> let f x y z:int = (x = y) && (y = z)

This annotates that f returns an int.  You need to use parens to make the 
:int bind to z and not to f.  This works:

# let f x y (z:int) = (x = y) && (y = z);;
val f : int -> int -> int -> bool = <fun>

This is another one of those shift-reduce conflicts that annoy me.

"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 

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