anchor.diff:  
   
   
  -
  +open System.Drawing
  +open System.Windows.Forms
   
   module Test =
  +
  +    type SketchState =
  +        { 
  +            finished : list<list<V2i>>
  +            current : list<V2i>
  +        }
  +
  +    let append (p : V2i) =
  +        State.modify (fun s -> { s with current = s.current @ [p]})
       
  -    let paintThingy (down : IObservable<_>) (up : IObservable<_>) (move : IObservable<_>) =
  +    let finish =
  +        State.modify (fun s -> { s with finished = s.finished @ [s.current]; current = [] })
  +
  +    let paintThingy (down : IObservable<MouseEventArgs>) (up : IObservable<MouseEventArgs>) (move : IObservable<MouseEventArgs>) =
           cont {
               let! d = down
  -            printfn "down"
  -
  -            let mutable res = []
  +            do! append (V2i(d.X, d.Y))
  +
               while Not (Cont.next up) do
                   let! m = move
  -                printfn "move"
  -                res <- m :: res
  +                do! append (V2i(m.X, m.Y))
                   
  -            printfn "up"
  -            return res
  -
  -        }
  -
  -
  -
  -open System.Windows.Forms
  +            do! finish
  +        }
  +
  +    let continuous (time : IObservable<DateTime>) (down : IObservable<MouseEventArgs>) (up : IObservable<MouseEventArgs>) =
  +        cont {
  +            let! d = down
  +
  +            let mutable old = DateTime.Now
  +            while Not (Cont.next up) do
  +                let! t = time
  +                printfn "%A" (t - old).TotalSeconds
  +                old <- t
  +
  +//            let! t = time
  +//            printfn "%A" (t - old).TotalSeconds  
  +//            do! finish
  +        }
  +
  +
  +
  +type MyForm<'s>(runner : ContRunner<'s>, paint : Graphics -> 's -> unit) as this =
  +    inherit Form()
  +
  +    let state = runner.State
  +    do this.SetStyle(ControlStyles.AllPaintingInWmPaint, true)
  +       this.SetStyle(ControlStyles.ResizeRedraw, true)
  +       this.SetStyle(ControlStyles.DoubleBuffer, true)
  +
  +    let invalidate() =
  +        this.BeginInvoke(new System.Action (fun () ->
  +            this.Invalidate()
  +        )) |> ignore
  +
  +    let subscription =
  +        state.AddMarkingCallback invalidate
  +
  +
  +    override x.OnPaintBackground(e) =
  +        ()
  +
  +    override x.OnPaint(e) =
  +        e.Graphics.CompositingQuality <- Drawing2D.CompositingQuality.HighQuality
  +        e.Graphics.SmoothingMode <- Drawing2D.SmoothingMode.AntiAlias
  +
  +        e.Graphics.Clear(Color.Black)
  +        printfn "get"
  +        let s = state.GetValue()
  +        paint e.Graphics s
  +        printfn "done"
  +        ()
  +
  +
  +
  +
  +
   
   
   
  
positive.code:         let d = delay r
          r := f(r)
          d
  
  type Future<'a> =
      | Later of (('a -> unit) -> IDisposable)
  
negative.code: 
  
  type ContRunner<'s>(state : 's) =
      let mutable state = state
  
      let time = new System.Reactive.Subjects.Subject<DateTime>()
  
      let modState = 
          Mod.custom (fun self -> 
              if time.HasObservers then
                  time.OnNext DateTime.Now
                  if time.HasObservers then
                      Mod.time.AddOutput self
              state
          )
  
      let mutable isInTime = false
  
      member x.Time = time :> IObservable<_>
  
      member x.State = modState :> IMod<_>
  
      member x.Push(c : Cont<'s, 'a>) =
          if not isInTime then
              isInTime <- true
              printfn "time"
              time.OnNext(DateTime.Now)
              isInTime <- false
  
          match c.run.Run(&state) with
              | Cancel -> ()
              | Result _ -> ()
              | Continue c ->
                  match c with
                      | Later s -> 
                          s x.Push |> ignore
  
          transact (fun () -> modState.MarkOutdated())
  
  
      
  