module C2HSState (
module State,
CST, runC2HS,
SwitchBoard(..), Traces(..), setTraces, traceSet,
putTraceStr, setSwitch, getSwitch)
where
import Control.Monad (when)
import State
import Switches (SwitchBoard(..), Traces(..),
initialSwitchBoard)
type CST s a = PreCST SwitchBoard s a
runC2HS :: (String, String, String) -> CST () a -> IO a
runC2HS :: forall a. (String, String, String) -> CST () a -> IO a
runC2HS (String, String, String)
vcd = (String, String, String)
-> SwitchBoard -> PreCST SwitchBoard () a -> IO a
forall e a. (String, String, String) -> e -> PreCST e () a -> IO a
run (String, String, String)
vcd SwitchBoard
initialSwitchBoard
setTraces :: (Traces -> Traces) -> CST s ()
setTraces :: forall s. (Traces -> Traces) -> CST s ()
setTraces Traces -> Traces
t = (SwitchBoard -> SwitchBoard) -> PreCST SwitchBoard s ()
forall e s. (e -> e) -> PreCST e s ()
updExtra (\SwitchBoard
es -> SwitchBoard
es {tracesSB = t (tracesSB es)})
traceSet :: (Traces -> Bool) -> CST s Bool
traceSet :: forall s. (Traces -> Bool) -> CST s Bool
traceSet Traces -> Bool
t = (SwitchBoard -> Bool) -> PreCST SwitchBoard s Bool
forall e a s. (e -> a) -> PreCST e s a
readExtra (Traces -> Bool
t (Traces -> Bool) -> (SwitchBoard -> Traces) -> SwitchBoard -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SwitchBoard -> Traces
tracesSB)
putTraceStr :: (Traces -> Bool) -> String -> CST s ()
putTraceStr :: forall s. (Traces -> Bool) -> String -> CST s ()
putTraceStr Traces -> Bool
t String
msg = do
set <- (Traces -> Bool) -> CST s Bool
forall s. (Traces -> Bool) -> CST s Bool
traceSet Traces -> Bool
t
when set $
hPutStrCIO stderr msg
setSwitch :: (SwitchBoard -> SwitchBoard) -> CST s ()
setSwitch :: forall s. (SwitchBoard -> SwitchBoard) -> CST s ()
setSwitch = (SwitchBoard -> SwitchBoard) -> PreCST SwitchBoard s ()
forall e s. (e -> e) -> PreCST e s ()
updExtra
getSwitch :: (SwitchBoard -> a) -> CST s a
getSwitch :: forall a s. (SwitchBoard -> a) -> CST s a
getSwitch = (SwitchBoard -> a) -> PreCST SwitchBoard s a
forall e a s. (e -> a) -> PreCST e s a
readExtra