Version française
Home     About     Download     Resources     Contact us    
Browse thread
Obj.magic and existential types.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: Obj.magic and existential types.

Le 19 juin 09 à 19:42, Guillaume Yziquel a écrit :

> But the result is rather interesting. It can record a flow of  
> computations, and recompute them only when upstream data has been  
> modified:

Not directly responding to your question but you are looking for  
functional reactive programming (frp).

http://erratique.ch/software/react

I rewrote your example below with react (no magic used).

Best,

Daniel

 > ocaml react.cmo
         Objective Caml version 3.11.0

# open React;;
# let n, set_n = S.create 1;;
val n : int React.signal = <abstr>
val set_n : int -> unit = <fun>
# let m = S.map (fun x -> x + 1) n ;;
val m : int React.signal = <abstr>
# S.value m;;
- : int = 2
# set_n 3;;
- : unit = ()
# S.value m;;
- : int = 4