Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE RankNTypes #-}
- module Main where
- import Reactive.Banana
- import Reactive.Banana.Frameworks
- import Reactive.Banana.Switch
- import Data.IORef
- import Control.Monad
- main = do
- fShowRef <- newIORef (const (return ()))
- fNumRef <- newIORef (const (return ()))
- let
- netDesc :: forall t. Frameworks t => Moment t ()
- netDesc = do
- (eNum, fNum) <- newEvent
- (eShow, fShow) <- newEvent
- liftIO (writeIORef fShowRef fShow)
- liftIO (writeIORef fNumRef fNum)
- let beh = stepper 0 eNum
- behTrimmed <- trimB beh
- reactimate (printInitial behTrimmed <$ eShow)
- actuate =<< compile netDesc
- fNum <- readIORef fNumRef
- fNum 1
- fShow <- readIORef fShowRef
- fShow ()
- printInitial :: AnyMoment Behavior Int -> IO ()
- printInitial beh = do
- let
- netDesc :: forall t. Frameworks t => Moment t ()
- netDesc = do
- behNow <- now beh
- initVal <- initial behNow
- liftIO (print initVal)
- -- compiling is enough, I just want to see the initial value
- void (compile netDesc)
- 1
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement