Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: William D. Neumann <wneumann@c...>
Subject: RE: [Caml-list] Why must types be always defined at the top level?
On Thu, 24 Jun 2004, John Hughes wrote:

> This from someone who uses "int" to mean something other than
> "integer"! :-)

Ah, but "real" = "real", but "int" <> "integer".
/clutching at straws?

> 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)
>
> so that it would be restricted to ints.

You can do this.  You just need to do:
# let f x y (z:int) = (x = y) & (y = z);;
val f : int -> int -> int -> bool = <fun>

What you have above is annotating f, not z.

William D. Neumann

---

"Well I could be a genius, if I just put my mind to it.
And I...I could do anything, if only I could get 'round to it.
Oh we were brought up on the space-race, now they expect you to clean toilets.
When you've seen how big the world is, how can you make do with this?
If you want me, I'll be sleeping in - sleeping in throughout these glory days."

	-- Jarvis Cocker

Think of XML as Lisp for COBOL programmers.

	-- Tony-A (some guy on /.)

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