| Portability | concurrency |
|---|---|
| Stability | experimental |
| Maintainer | John Launchbury, john@galois.com |
| Safe Haskell | None |
Control.Concurrent.StdInOut
Description
A low-tech concurrent interface to the console. When multiple threads want input, they send messages to the console with the format
<thread-id>:request
The user supplies input to any requesting thread in a similar way:
<thread-id>:response
At any time, the user can enter !! to obtain a listing of all the
active prompts. Any input not of either of these forms is discarded.
example :: IO ()
example = setupStdinout processes
processes :: IO ()
processes = do
forkIO $ (prompt "Enter something" >> return ())
forkIO $ (prompt "Something else" >> return ())
prompt "quit" -- When the main thread dies,
return () -- the whole interaction ends
- setupStdInOut :: IO a -> IO a
- prompt :: HasFork io => String -> io String
- putStrLine :: MonadIO io => String -> io ()
Documentation
setupStdInOut :: IO a -> IO aSource
setupStdInOut establishes the context for prompt, by running
a daemon while its argument is executing. The daemon is terminated
once the argument to setupStdInOut finishes.
putStrLine :: MonadIO io => String -> io ()Source
putStrLine sends output to stdout, ensuring that lines are whole
and uninterrupted (including the final newline).