id	summary	reporter	owner	description	type	status	priority	milestone	version	resolution	keywords	cc
13	Snapshotting a Behavior built with accumB seems to go wrong	EyalLotem		"You can replace:
{{{
                            doesntWork ui
                            --works ui
}}}
with snap, and it will still not work, but ""works ui"" will work.  This demonstrates the problem is with snapshotting the behavior.

The code builds a behavior by accumulating all of the keyboard events (into a string in this example, for simplicity's sake. In my real code, I actually capture Up/Down events and build a Set of pressed keys). This Behavior seems to be fine, however, snapshotting it against a regular ticker seems to fail completely.

Here is the code:
{{{
{-# OPTIONS -fglasgow-exts -Wall #-}

module Main where

import Control.Applicative
import qualified FRP.Reactive as R
import qualified Graphics.FieldTrip as FT
import Graphics.FieldTrip((*%))
import qualified FRP.Reactive.FieldTrip.Adapter as FieldTripA
import qualified FRP.Reactive.GLUT.Adapter as GLUTA

keysPressed :: GLUTA.UI -> R.Behavior String
keysPressed ui = R.accumB """" (setAction <$> GLUTA.keyPressed ui)
    where
      setAction = (++) . (++"" "") . show

main :: IO ()
main = do
  let ticker = R.atTimes [0,0.15..]
      incTicker = R.accumE 0 ((+1) <$ ticker) :: R.Event Integer
      snap ui = R.stepper """" $ incTicker `R.snapshot_` keysPressed ui
      works ui = keysPressed ui
      doesntWork ui = liftA2 (,) (works ui) (snap ui)
  FieldTripA.anim3 $ \ui -> ((FT.uscale3 (0.2::Double) *%) . FT.flatG . FT.utext . show) <$>
                            doesntWork ui
                            --works ui
}}}
"	defect	closed	blocker			duplicate		
