anchor.diff:          
       let ofObservable (o : IObservable<'a>) =
           o |> EventSource.ofObservable |> ofEventSource
  +
  +    let ofMod (m : IMod<'a>) =
  +        m |> EventSource.ofMod |> ofEventSource
  +
  +    let now<'s> : SF<'s, float> =
  +        { run = State.get |> State.map (fun s -> Finished s.time) }
  +
  +    let nextTime<'s> : SF<'s, float> =
  +        { run = State.get |> State.map (fun s -> Continue(TimePattern.Instance,fun _ -> { run = State.get |> State.map (fun s -> Finished s.time) })) }
  +
  +    let dt<'s> : SF<'s, float> =
  +        { run = 
  +            State.get |> State.map (fun s -> 
  +                let start = s.time
  +                Continue(TimePattern.Instance,fun _ -> { run = State.get |> State.map (fun s -> Finished (s.time - start)) })
  +            ) 
  +        }
   
   
       let rec map (f : 'a -> 'b) (m : SF<'s, 'a>) =
  
positive.code:                 let g = e.Graphics
                  g.Clear(Color.Black)
  
                  g.Line(Color.Red, s.current)
  
                  for p in s.finished do
                      g.Polygon(Color.Green, p)
  
      let run() =
          let runner = Runner { current = []; finished = [] }
          use form = new UI.PaintForm(runner.State)
  
  
          let thing = paintThingy form.MouseDown form.MouseUp form.MouseMove |> SF.ignore |> SF.repeat
          runner.Enqueue thing
  
  
          Application.Idle.Add (fun _ -> runner.Step())
          Application.Run(form)
  
negative.code:                     | Some r -> Some (Choice<obj, obj>.Choice2Of2 r :> obj)
                      | None -> None
  
  type TimePattern private () =
      inherit Pattern(PersistentHashSet.empty)
      static let instance = TimePattern() :> Pattern
      static member Instance = instance
      
      override x.Run(s,v) =
          Some null
  
  type NeverPattern private () =
      inherit Pattern(PersistentHashSet.empty)
      static let instance = NeverPattern() :> Pattern
      static member Instance = instance
      
      override x.Run(s,v) =
          None
  
  
  type MultiDict<'k, 'v when 'k : equality>() =
      let store = Dictionary<'k, List<'v>>()
  
      member x.ContainsKey (key : 'k) =
          store.ContainsKey key
  
      member x.Add(key : 'k, value : 'v) =
          let list = 
              match store.TryGetValue key with
                  | (true, l) -> l
                  | _ ->
                      let list = List()
                      store.[key] <- list
                      list
  
          list.Add value
  
      member x.Keys = store.Keys
  
      interface System.Collections.IEnumerable with
          member x.GetEnumerator() = store.GetEnumerator() :> _
  
      interface System.Collections.Generic.IEnumerable<KeyValuePair<'k, List<'v>>> with
          member x.GetEnumerator() = store.GetEnumerator() :> _
  
  
  type Runner<'s>(state : 's) =
      inherit Mod.AbstractMod<'s>()
  
      let subscriptions = Dictionary<IEventSource, IDisposable>()
  
      let mutable pending : MultiDict<Pattern, obj -> SF<'s, unit>> = MultiDict()
      let queue = Queue<IEventSource * obj * float>()
      let mutable state = { time = 0.0; state = state }
      let sw = System.Diagnostics.Stopwatch()
      do sw.Start()
  
      let mutable dependsOnTime = false
  
  
      let now () = sw.Elapsed.TotalSeconds
  
      override x.Compute() =
          x.Evaluate()
              
          if dependsOnTime then
              AdaptiveObject.Time.Outputs.Add x |> ignore
              
          state.state
  
      member private x.Push(source : IEventSource, value : obj) =
          queue.Enqueue(source, value, now())
          transact (fun () -> x.MarkOutdated())
  
      member x.Enqueue(sf : SF<'s, unit>) =
          lock x (fun () ->
              match sf.run.Run(&state) with
                  | Finished _ -> ()
                  | Continue(p, cont) ->
                      pending.Add(p, cont)
  
                      if p = TimePattern.Instance then
                          dependsOnTime <- true
  
                      for r in p.Relevant do
                          if not (subscriptions.ContainsKey r) then
                              subscriptions.[r] <- r.Subscribe(fun o -> x.Push(r, o))
          )
                              
      member private x.Step() =
          lock x (fun () ->
              while queue.Count > 0 do
                  let (s,e,t) = queue.Dequeue()
                  state <- { state with time = t }
  
                  let mutable newPending = MultiDict()
                  for KeyValue(p, conts) in pending do
                      match p.Run(s,e) with
                          | Some v -> 
                              for cont in conts do
                                  let c = cont v
                                  match c.run.Run(&state) with
                                      | Continue(p,c) ->
                                          newPending.Add(p, c)
                                      | _ ->
                                          ()
                          | None ->
                              for cont in conts do
                                  newPending.Add(p,cont)
  
                  let oldEvents   = pending.Keys |> Seq.collect (fun p -> p.Relevant) |> HashSet
                  let newEvents   = newPending.Keys |> Seq.collect (fun p -> p.Relevant) |> HashSet
  