Safe Haskell | None |
---|---|
Language | Haskell2010 |
An example of a Box for the command line.
Synopsis
- data ControlRequest
- data ControlResponse
- data Toggle
- type ControlBox a b m = MonadConc m => Cont m (Box (STM m) (Either ControlResponse a) (Either ControlRequest b))
- type ControlBox_ m = MonadConc m => Cont m (Box (STM m) ControlResponse ControlRequest)
- data ControlConfig = ControlConfig {}
- defaultControlConfig :: ControlConfig
- consoleControlBox :: ControlBox Text Text IO
- consoleControlBox_ :: ControlBox_ IO
- parseControlRequest :: Parser a -> Parser (Either ControlRequest a)
- controlBox :: ControlConfig -> IO a -> Box (STM IO) ControlResponse ControlRequest -> IO ()
- controlBoxProcess :: ControlConfig -> ProcessConfig Handle Handle () -> Box (STM IO) (Either ControlResponse Text) (Either ControlRequest Text) -> IO ()
- controlConsole :: Cont IO (Box (STM IO) (Either ControlResponse Text) (Either ControlRequest Text))
- testBoxManual :: ControlConfig -> Double -> IO () -> IO ()
- testBoxAuto :: ControlConfig -> Double -> [(ControlRequest, Double)] -> IO () -> IO ()
- beep :: Int -> Int -> Double -> IO ()
- timeOut :: Double -> ControlBox m a b
- timedRequests :: MonadConc m => [(ControlRequest, Double)] -> Cont m (Emitter (STM m) ControlRequest)
- testCatControl :: ControlConfig -> IO ()
Documentation
data ControlRequest Source #
request ADT
Instances
data ControlResponse Source #
response ADT
Instances
type ControlBox a b m = MonadConc m => Cont m (Box (STM m) (Either ControlResponse a) (Either ControlRequest b)) Source #
A Box
that communicates via ControlRequest
and ControlResponse
or an underlying typed-channel
type ControlBox_ m = MonadConc m => Cont m (Box (STM m) ControlResponse ControlRequest) Source #
A Box
that only communicates via ControlRequest
and ControlResponse
data ControlConfig Source #
Instances
Eq ControlConfig Source # | |
Defined in Box.Control (==) :: ControlConfig -> ControlConfig -> Bool # (/=) :: ControlConfig -> ControlConfig -> Bool # | |
Ord ControlConfig Source # | |
Defined in Box.Control compare :: ControlConfig -> ControlConfig -> Ordering # (<) :: ControlConfig -> ControlConfig -> Bool # (<=) :: ControlConfig -> ControlConfig -> Bool # (>) :: ControlConfig -> ControlConfig -> Bool # (>=) :: ControlConfig -> ControlConfig -> Bool # max :: ControlConfig -> ControlConfig -> ControlConfig # min :: ControlConfig -> ControlConfig -> ControlConfig # | |
Show ControlConfig Source # | |
Defined in Box.Control showsPrec :: Int -> ControlConfig -> ShowS # show :: ControlConfig -> String # showList :: [ControlConfig] -> ShowS # |
defaultControlConfig :: ControlConfig Source #
Default is one start, manual start and no autorestart.
consoleControlBox :: ControlBox Text Text IO Source #
a command-line control box.
consoleControlBox_ :: ControlBox_ IO Source #
a command-line control box.
parseControlRequest :: Parser a -> Parser (Either ControlRequest a) Source #
Parse command line requests
controlBox :: ControlConfig -> IO a -> Box (STM IO) ControlResponse ControlRequest -> IO () Source #
an effect that can be started, stopped and restarted (a limited number of times)
controlBoxProcess :: ControlConfig -> ProcessConfig Handle Handle () -> Box (STM IO) (Either ControlResponse Text) (Either ControlRequest Text) -> IO () Source #
an effect that can be started, stopped and restarted (a limited number of times)
controlConsole :: Cont IO (Box (STM IO) (Either ControlResponse Text) (Either ControlRequest Text)) Source #
testBoxManual :: ControlConfig -> Double -> IO () -> IO () Source #
manual testing > testBoxManual (ControlConfig 1 True (Just 0.5) False) 2.3 (beep 3 1 0.5) Status (On,0) beep 1 beep 2 beep 3 Left ShutDown
testBoxAuto :: ControlConfig -> Double -> [(ControlRequest, Double)] -> IO () -> IO () Source #
auto testing FIXME: Doesn't work with doctest > testBoxAuto (ControlConfig 5 True (Just 0.2) False) 5 [(Check, 0.1), (Start,0.1), (Stop,1), (Start, 0.1), (Check, 0.1), (Reset,0.1)] (beep 2 1 1) Left (Status (On,5)) Left (Status (On,4)) Left (Status (On,4)) beep 1 Left (Status (Off,4)) Left (Status (On,4)) Left (Status (On,3)) Left (Status (On,2)) beep 1 beep 2 beep 1 Left ShuttingDown
testBoxAuto (ControlConfig 1 True (Just 0.5) False) 3 [(Reset,1.1), (Quit, 1)] (beep 3 1 1) Left (Status (On,1)) beep 1 Left ShuttingDown Left (Status (On,-1))
timeOut :: Double -> ControlBox m a b Source #
A box with a self-destruct timer.
timedRequests :: MonadConc m => [(ControlRequest, Double)] -> Cont m (Emitter (STM m) ControlRequest) Source #
a canned ControlRequest emitter with delays
testCatControl :: ControlConfig -> IO () Source #