Skip to content

@aforemny /Main.hs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Reactive Banana as Library
module Main where
import Control.Concurrent (forkIO, threadDelay)
import Control.Monad (forever)
import Data.Time (getCurrentTime)
import Reactive.Banana
main = do
(clock, clockSink) <- newAddHandler
forkIO $ forever $ getCurrentTime >>= clockSink >> sleep
(int, intSink) <- newAddHandler
forkIO $ mapM_ ((>> sleep) . intSink) [1..]
time0 <- getCurrentTime
library $ do
clockB <- fromChanges time0 clock
intB <- fromChanges 0 int
return $ liftA2 (\s t -> show s ++ " " ++ show t) clockB intB
where
sleep = threadDelay (10^6)
library subnet = do
network <- compile $ do
stringE <- changes =<< subnet
reactimate $ print <$> stringE
actuate network
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.