Skip to content

Instantly share code, notes, and snippets.

@lattenwald
Created March 25, 2015 08:30
Show Gist options
  • Save lattenwald/59d36b9cc3383cef8882 to your computer and use it in GitHub Desktop.
Save lattenwald/59d36b9cc3383cef8882 to your computer and use it in GitHub Desktop.
netwire integralWith' (integralWith, correction function has time (a -> a))
integralWith'
:: (W.HasTime t s, Fractional a)
=> (a -> a) -- ^ Correction function.
-> a -- ^ Integration constant (aka start value).
-> W.Wire s e m a a
integralWith' correct = loop
where
loop x' =
W.mkPure $ \ds dx ->
let dt = realToFrac (W.dtime ds)
x = correct (x' + dt*dx)
in x' `seq` (Right x', loop x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment