Haskell Netwire
What does the package do
Where is the example for the Netwire
Netwire Package but the author will deprecate the package
Minimal Example
liftIO :: (MonadIO m) => IO a -> m a
{-# LANGUAGE RankNTypes #-}
import Prelude hiding ((.)) -- To use (.) in the scope of Categories instead
import Control.Wire
import FRP.Netwire
import Control.Monad.IO.Class
import System.IO
testWireX ::
(MonadIO m, Show b, Show e)
=> Session m s
-> (forall a. Wire s e Identity a b)
-> m c
testWireX s0 w0 = loop s0 w0
where
loop s' w' = do
(ds, s) <- stepSession s'
let Identity (mx, w) = stepWire w' ds (Right ())
liftIO $ do
putChar '\r'
putStr $ show mx
putStr "--"
putStr (either (\ex -> "I: " ++ show ex) show mx)
putStr "\027[K"
hFlush stdout
loop s w
testMe::(MonadIO m, Show b, Show e)
=> Session m s
-> (forall a. Wire s e Identity a b)
-> m ()
testMe s0 w0 = do
(ds, s) <- stepSession s0
let Identity (mx, w) = stepWire w0 ds (Right ())
liftIO $ do
putChar '\r'
putStr $ "mx=" ++ show mx
hFlush stdout
speed :: Float
speed = 0.5
-- We're changing the e value to () because it has a Show instance
pos :: (HasTime t s, Monad m) => Wire s () m a Float
pos = integral 0 . pure speed
-- The main function
main :: IO ()
main = testWireX clockSession_ pos