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: | moj@u... |
| Subject: | Re: [Caml-list] Polymorphism and the "for" loop |
> # let f = ref None;;
> val f : '_a option ref = {contents = None}
> # let store_f f' = f := Some f';;
> val store_f : '_a -> unit = <fun>
>
> (I want store_f to have type (unit -> 'a) -> unit.)
You can write
# let store_f f' = f := Some (fun () -> ignore (f'()));;
val store_f : (unit -> 'a) -> unit = <fun>
- Matti Jokinen
-------------------
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