Browse thread
[Caml-list] Polymorphism and the "for" loop
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jon@j...> |
| Subject: | [Caml-list] Polymorphism and the "for" loop |
Considering the following code objects to the expression in the "for" loop not having the type "unit": # for i=0 to 3 do 1 done;; Warning: this expression should have type unit. - : unit = () why is "g" in the following code inferred to have the polymorphic type (unit -> 'a) rather than (unit -> unit)? # let f g = for i=0 to 3 do g () done;; val f : (unit -> 'a) -> unit = <fun> Cheers, Jon. ------------------- 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