Mercurial > gui
diff sourceL.ur @ 15:8300d5f0dc19
Replace ChangePoller with SourceL, plus some other rearrangements
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 07 Aug 2011 14:38:52 -0400 |
parents | changePoller.ur@0827320b0f04 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sourceL.ur Sun Aug 07 14:38:52 2011 -0400 @@ -0,0 +1,22 @@ +con t a = {Source : source a, + OnSet : source (a -> transaction {})} + +fun create [a] (i : a) = + s <- source i; + f <- source (fn _ => return ()); + + return {Source = s, + OnSet = f} + +fun onChange [a] (t : t a) f = + old <- get t.OnSet; + set t.OnSet (fn x => (old x; f x)) + +fun set [a] (t : t a) (v : a) = + Basis.set t.Source v; + f <- get t.OnSet; + f v + +fun get [a] (t : t a) = Basis.get t.Source + +fun value [a] (t : t a) = signal t.Source