A bottleneck for UI from multiple threads. Prevents mixing of output
messages. Also makes possible a primitive form of input. By mastering
and cuisUIInput_E
it's possible
to construct cuisUIOutput_E
with different than UI I/O.
ConcurrentUISupport
- type AskerID = String
- type ReadFromConsoleStr = String
- type ThreadFinisher = IO ()
- data CUISCommand
- data ConcurrentUISupport = ConcurrentUISupport {
- cuisInputTChan :: TChan [CUISCommand]
- cuisOutputChans :: TVar (Map AskerID (TChan ReadFromConsoleStr))
- cuisFinish :: ThreadFinisher
- cuisSupporterStopCheck :: STM Bool
- cuisFinalizer :: IO ()
- cuisUIInput_E :: Either (STM String) (IO String)
- cuisUIOutput_E :: Either (String -> STM ()) (String -> IO ())
- cuisPressAnyKey_uiCmd :: Maybe (IO ())
- cuisPressAnyKey_linesCountCond :: Maybe Int
- defaultConcurrentUISupportIO :: IO ConcurrentUISupport
- defaultConcurrentUISupportIO_logInFile :: FilePath -> IOMode -> IO ConcurrentUISupport
- cuisUIInput :: ConcurrentUISupport -> IO String
- cuisUIOutput :: ConcurrentUISupport -> String -> IO ()
- cuisInput :: ConcurrentUISupport -> [CUISCommand] -> IO ()
- acquirePutStr_fromCmdsList :: [CUISCommand] -> Maybe CUISCommand
- acquireReadStr_fromCmdsList :: [CUISCommand] -> Maybe CUISCommand
- runConcurrentUISupport :: ConcurrentUISupport -> IO ()
- cuisWriteSTM :: ConcurrentUISupport -> String -> STM ()
- cuisWrite :: ConcurrentUISupport -> String -> IO ()
- cuisNewPage :: ConcurrentUISupport -> IO ()
- cuisReadLn :: ConcurrentUISupport -> AskerID -> IO ReadFromConsoleStr
- reportExceptionIfAny :: (String -> IO ()) -> String -> IO a -> IO a
- printExceptionIfAny :: String -> IO a -> IO a
- reportExceptionIfAny_2 :: ConcurrentUISupport -> String -> IO a -> IO a
- reportExceptionIfAnySTM :: (String -> STM ()) -> String -> STM a -> STM a
- reportExceptionIfAnySTM_2 :: ConcurrentUISupport -> String -> STM a -> STM a
ConcurrentUISupport administration
type ReadFromConsoleStr = StringSource
type ThreadFinisher = IO ()Source
data CUISCommand Source
data ConcurrentUISupport Source
ConcurrentUISupport | |
|
defaultConcurrentUISupportIO_logInFile :: FilePath -> IOMode -> IO ConcurrentUISupportSource
UI in console + log to file.
cuisUIInput :: ConcurrentUISupport -> IO StringSource
Whatever
is - cuisUIInput_E
Left
or Right
- flattern it into IO.
cuisUIOutput :: ConcurrentUISupport -> String -> IO ()Source
Whatever
is - cuisUIOutput_E
Left
or Right
- flattern it into IO.
cuisInput :: ConcurrentUISupport -> [CUISCommand] -> IO ()Source
Not to be confised with
, which interfaces with user.
This input interfaces with threads, that makes use of it.
cuisUIInput
A wrapper around
.
cuisInputTChan
Use these functions to deal with ConcurrentUISupport
cuisWriteSTM :: ConcurrentUISupport -> String -> STM ()Source
Few helpers for dealing with exceptions
printExceptionIfAny :: String -> IO a -> IO aSource
reportExceptionIfAny_2 :: ConcurrentUISupport -> String -> IO a -> IO aSource
reportExceptionIfAnySTM_2 :: ConcurrentUISupport -> String -> STM a -> STM aSource