anchor.diff:                      nv, switch gc onEvent nc
           )
   
  -    let rec integrate (seed : 's) (acc : 's -> 'a -> 's) (m : sf<'x, 'a>) =
  +    let rec fold (seed : 's) (acc : 's -> 'a -> 's) (m : sf<'x, 'a>) =
           custom m.dependencies (fun _ ctx x ->
               let (mv,mc) = m.run ctx x
               let s = acc seed mv
  -            s, integrate s acc mc
  -        )
  -
  -    let rec switchTrue (guard : sf<'a, bool>) (ifTrue : sf<'a, 'b>) (ifFalse : sf<'a, 'b>) =
  -        let deps = List.concat [guard.dependencies; ifTrue.dependencies; ifFalse.dependencies]
  -        custom deps (fun _ ctx a ->
  -            let (gv, gc) = guard.run ctx a
  -            if gv then
  -                let (ev, ec) = ifTrue.run ctx a
  -                ev, switchTrue gc ec ifFalse
  -
  -            else
  -                let (nv, nc) = ifFalse.run ctx a
  -                nv, switchTrue gc ifTrue nc
  -        )
  +            s, fold s acc mc
  +        )
  +
  +    let rec zip (l : sf<'a, 'b>) (r : sf<'a, 'c>) =
  +        custom (l.dependencies @ r.dependencies) (fun self ctx a ->
  +            let (lv, lc) = l.run ctx a
  +            let (rv, rc) = r.run ctx a
  +
  +            (lv,rv), zip lc rc
  +
  +        )
  +
  +    let inline integrate (f : sf<'a, 'b>) =
  +        f |> fold LanguagePrimitives.GenericZero (+)
  +
  +    let inline differentiate (y : sf<'a, 'y>) (x : sf<'a, 'x>) =
  +        zip y x 
  +            |> fold None (fun last (y,x) ->
  +                match last with
  +                    | Some (_, oy,ox) ->
  +                        let v = (y - oy) / (x - ox)
  +                        Some(v, y, x)
  +                    | None ->
  +                        Some(LanguagePrimitives.GenericZero, y, x)
  +               ) 
  +            |> mapOut (fun o ->
  +                match o with
  +                    | Some(v,_,_) -> v
  +                    | _ -> LanguagePrimitives.GenericZero
  +               )
  +
  +
  +    let switchTrue (guard : sf<'a, bool>) (ifTrue : sf<'a, 'b>) (ifFalse : sf<'a, 'b>) =
  +        let rec run (currentlyTrue : Option<bool>) (guard : sf<'a, bool>) (ifTrue : sf<'a, 'b>) (ifFalse : sf<'a, 'b>) =
  +            let deps = 
  +                match currentlyTrue with
  +                    | Some true -> guard.dependencies @ ifTrue.dependencies
  +                    | Some false -> guard.dependencies @ ifFalse.dependencies
  +                    | None -> List.concat [guard.dependencies; ifTrue.dependencies; ifFalse.dependencies]
  +
  +            custom deps (fun _ ctx a ->
  +                let (gv, gc) = guard.run ctx a
  +                if gv then
  +                    let (ev, ec) = ifTrue.run ctx a
  +                    ev, run (Some true) gc ec ifFalse
  +
  +                else
  +                    let (nv, nc) = ifFalse.run ctx a
  +                    nv, run (Some false) gc ifTrue nc
  +            )
    
  -
  +        run None guard ifTrue ifFalse
   
       let latest (m : IMod<'a>) : sf<'x, 'a> =
           custom [] (fun self ctx _ ->
  
positive.code: 
              latestValue, self
          )
  
      type private Reactimator<'a, 'b>(sf : sf<'a, 'b>, input : 'a, output : 'b -> unit) as this =
          inherit AdaptiveObject()
  
negative.code:             member x.run _ _ = raise EndExn
              member x.dependencies = []   
  
      type private TimeSignal<'a> private() =
          static let instance = TimeSignal<'a>() :> sf<'a, DateTime>
  
          static member Instance = instance
  
          interface sf<'a, DateTime> with
              member x.run ctx _ = DateTime.Now, instance
              member x.dependencies = [Time]
  
  
      let time<'a> = TimeSignal<'a>.Instance
  
      let stop<'a, 'b> = EndSignal<'a, 'b>.Instance
  
  