atzeus / FRPNow

Other
89 stars 14 forks source link

integrate is wrong by a factor of two #15

Closed ocharles closed 9 years ago

ocharles commented 9 years ago

The following program

module Main where

import Control.Monad
import Control.Concurrent
import Control.FRPNow

main :: IO ()
main =
  (print :: Double -> IO ()) =<<
  runNowMaster (do e <- async (threadDelay 10000)
                   let clock = pure 0 `switch` (pure 1 <$ e) :: Behavior Double
                       speed = 1 :: Double
                   distance <- sample (integrate clock (pure speed))
                   traceChanges "Distance: " distance
                   return never)

outputs

Distance: 0.0
Distance: 0.5

Given a speed of 1 unit/tick, I'd expect that after 1 tick I had travelled 1 units, rather than 0.5.

atzeus commented 9 years ago

Thanks! Fixed in the next version.