view clock.ur @ 10:0337f88f2efc

Clock
author Adam Chlipala <adam@chlipala.net>
date Fri, 22 Jul 2011 15:40:03 -0400
parents
children ccd0a169e827
line wrap: on
line source
(** Reactive view of the current time *)

type t = { Source : source time,
           Period : int }

fun create ms =
    tm <- now;
    t <- source tm;
    return {Source = t, Period = ms}

fun start t =
    let
        fun loop () =
            sleep t.Period;
            tm <- now;
            set t.Source tm;
            loop ()
    in
        spawn (loop ())
    end

fun signal t = Basis.signal t.Source