netspec-0.2.0.0: Simplify static Networking tasks

Safe HaskellSafe-Infered

Network.NetSpec.Text

Contents

Description

Use Text to send and receive messages. For this module, a message is a single line; the newline character acts as the end-of-message flag.

Synopsis

Receiving

receive :: MonadIO io => Handle -> io TextSource

Receive a Text message from a Handle.

Sending

(!) :: (CanSend h, MonadIO io) => h -> Text -> io ()Source

The staple for sending a message. ! is typeclassed so that you can send or broadcast using the same simple syntax. The CanSend typeclass is not exposed. Instances of CanSend include Handle and Traversable t => t Handle.

! produces an IO action lifted into any MonadIO, so can be used without the extra cruft of liftIO for most monad stacks. ! is declared as infix 2.

Usage:

 destination ! someText

send :: MonadIO io => Handle -> Text -> io ()Source

Send a Text message to exactly one Handle.

broadcast :: MonadIO io => Foldable f => f Handle -> Text -> io ()Source

Broadcast a Text message to multiple Handles.

Re-exports