Some guy insists "true FRP principle" as follows:
A (FRP) library user will describe a mapping
f
asCurrent TimeStamp => State
by referential transparent function or stream.
A system applies the System TimeStamp(
t=0,1,2...
) to thef
Accordingly, A system obtains State:
f(0),f(1),f(2),....
This should be the "true FRP basic principle".
The guy also shown the following code as a "proof of the concept".
The original source is from http://anond.hatelabo.jp/20160518122300
(Haskell ReactiveBanana)
ReactiveBananaDrawingCanvas.hs
import Data.Monoid (mconcat)
import Reactive.Banana (accumB)
import Graphics.Gloss.Interface.Pure.Game
import Graphics.Gloss.Interface.FRP.ReactiveBanana (playBanana)
main = playBanana disp colour freq gen
where
disp = (InWindow "Drawing Canvas" (400, 400) (40, 40))
colour = white
freq = 100
gen deltaTime = return . fmap draw . accumB (False,[],[]) . fmap eTrans
draw (_, path, paths) = mconcat $ map line $ path:paths
eTrans (EventKey (MouseButton LeftButton) Down _ _ ) (_, path, paths) = (True, path, paths)
eTrans (EventKey (MouseButton LeftButton) Up _ _ ) (_, path, paths) = (False, [], path:paths)
eTrans (EventMotion pos) (True, path, paths) = (True, pos:path, paths)
eTrans _ world = world
playIO display colour frequency ()
(\ _ → readIORef pictureref)
(\ ev _ → () <$ event ev)
(\ time _ → () <$ tick time)
https://hackage.haskell.org/package/gloss-1.10.1.1/docs/src/Graphics-Gloss-Interface-IO-Game.html
playIO display backColor simResolution
worldStart worldToPicture worldHandleEvent worldAdvance
= playWithBackendIO defaultBackendState
display backColor simResolution
worldStart worldToPicture worldHandleEvent worldAdvance
False
, Callback.Idle (callback_simulate_idle
stateSR animateSR (readIORef viewSR)
worldSR (\_ -> worldAdvance)
singleStepTime)
I don't get it. The code presented as a "proof of the concept" is nothing to do with the "true FRP principle" that he claims, I think.
I am not a user of ReactiveBanana, so I'd like to double-check by people here. Thanks.