Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Mechanism to get messages sent to a handle concurrently
without getting them mixed. They are sent to the handle in the same
order they are received by a passer object (see Passer
), not
sending a message before the previous message is sent completely.
- data Passer handle msg
- createPasser :: handle -> (handle -> msg -> IO ()) -> IO (Passer handle msg)
- closePasser :: Passer handle msg -> IO ()
- postMessage :: Passer handle msg -> msg -> IO Bool
- isPasserClosed :: Passer handle msg -> IO Bool
- isPasserOpen :: Passer handle msg -> IO Bool
- passerHandle :: Passer handle msg -> handle
Passer type
The Passer
is the object that you send the messages to.
It will redirect this message to its attached handle,
making sure the messages are not intercalated.
Use postMessage
to send message to a passer object.
Open/Close a passer
:: handle | Handle to use |
-> (handle -> msg -> IO ()) | Function to send messages to the handle |
-> IO (Passer handle msg) |
Create a passer object from a handle and a function to send values to that handle.
Example:
createPasser stderr hPutStrLn
closePasser :: Passer handle msg -> IO () Source
Close a passer object, so it won't receive any more messages
in the future. Once a passer object is closed, it can't be
re-opened again. If you want to reuse a handle, create another
passer object with createPasser
.
Send messages to the passer
postMessage :: Passer handle msg -> msg -> IO Bool Source
Send a message to a passer object. It returns a value indicating if the message reached the passer object.
Check passer status
isPasserClosed :: Passer handle msg -> IO Bool Source
Check if a passer object is closed. When a passer object is closed, it won't send any more messages to its attached handle. This does not mean the handle itself is closed.
isPasserOpen :: Passer handle msg -> IO Bool Source
Check if a passer object is open. While a passer object is open, all the messages received by the passer are sent to its attached handle.
Handle
passerHandle :: Passer handle msg -> handle Source
Return the handle used by a passer object.