module Control.Wire.Run
(
testWire,
testWireM
)
where
import Control.Monad.IO.Class
import Control.Wire.Core
import Control.Wire.Session
import Data.Functor.Identity
import System.IO
testWire ::
(MonadIO m, Show b, Show e)
=> Session m s
-> (forall a. Wire s e Identity a b)
-> m c
testWire 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 (either (\ex -> "I: " ++ show ex) show mx)
putStr "\027[K"
hFlush stdout
loop s w
testWireM ::
(Monad m', MonadIO m, Show b, Show e)
=> (forall a. m' a -> m a)
-> Session m s
-> (forall a. Wire s e m' a b)
-> m c
testWireM run s0 w0 = loop s0 w0
where
loop s' w' = do
(ds, s) <- stepSession s'
(mx, w) <- run (stepWire w' ds (Right ()))
liftIO $ do
putChar '\r'
putStr (either (\ex -> "I: " ++ show ex) show mx)
putStr "\027[K"
hFlush stdout
loop s w