id	summary	reporter	owner	description	type	status	priority	milestone	version	resolution	keywords	cc
26	Strange performance behaviour	cgibbard		"In the following program, velocity is computed as the sum of the integral of an acceleration term derived from keyboard input, and the position of the mouse. If I comment out the liftA2 (^+^) and either one of the two sources of velocity, the performance is smooth. However, taking the sum like this makes the program very jerky and unresponsive. Compiling with optimisations does not appear to help. Is it just my machine?

{{{
import Control.Applicative
import Data.VectorSpace
import FRP.Reactive
import FRP.Reactive.GLUT.Adapter
import Graphics.FieldTrip
import FRP.Reactive.FieldTrip

main = anim2 myDisk

myDisk ui = motion . pure $ uscale2 (0.1 :: Double) *% udisk
  where motion = liftA2 (*%) (fmap translate2 (position ui))

position = uiIntegral velocity

velocity ui = liftA2 (^+^)
                (uiIntegral accel ui)
                (fmap (uncurry vector2) (mousePosition ui))

accel ui = keyAccel ui 

keyAccel :: Anim (Vector2 Double)
keyAccel ui = accumB zeroV . fmap f $ keyAction ui
  where f (Down, k) = (^+^ keyMotion k)
        f (Up, k)   = (^-^ keyMotion k)

keyMotion (SpecialKey KeyUp)    = vector2 0 1
keyMotion (SpecialKey KeyDown)  = vector2 0 (-1)
keyMotion (SpecialKey KeyLeft)  = vector2 (-1) 0
keyMotion (SpecialKey KeyRight) = vector2 1 0
keyMotion _ = zeroV
}}}"	defect	new	major					cgibbard@…
