hosc-0.20: Haskell Open Sound Control

Safe Haskell | Safe-Inferred
Language | Haskell2010

Sound.Osc.Transport.Monad

Contents

- Send
- Receive
- Wait

Description

Monad class implementing an Open Sound Control transport.

Synopsis

- class Monad m => SendOsc m where
  - sendPacket :: Packet -> m ()
- class Monad m => RecvOsc m where
  - recvPacket :: m Packet
- class (SendOsc m, RecvOsc m) => DuplexOsc m
- class (DuplexOsc m, MonadIO m) => Transport m
- type Connection t a = ReaderT t IO a
- withTransport :: Transport t => IO t -> Connection t r -> IO r
- withTransport_ :: Transport t => IO t -> Connection t r -> IO ()
- sendMessage :: SendOsc m => Message -> m ()
- sendBundle :: SendOsc m => Bundle -> m ()
- recvBundle :: RecvOsc m => m Bundle
- recvMessage :: RecvOsc m => m (Maybe Message)
- recvMessage_err :: RecvOsc m => m Message
- recvMessages :: RecvOsc m => m [Message]
- waitUntil :: RecvOsc m => (Packet -> Bool) -> m Packet
- waitFor :: RecvOsc m => (Packet -> Maybe a) -> m a
- waitImmediate :: RecvOsc m => m Packet
- waitMessage :: RecvOsc m => m Message
- waitAddress :: RecvOsc m => Address_Pattern -> m Packet
- waitReply :: RecvOsc m => Address_Pattern -> m Message
- waitDatum :: RecvOsc m => Address_Pattern -> m [Datum]

# Documentation

class Monad m => SendOsc m where Source #

Sender monad.

Methods

sendPacket :: Packet -> m () Source #

Encode and send an Osc packet.

#### Instances

Instances details

(Transport t, MonadIO io) => SendOsc (ReaderT t io) Source # | `SendOsc` over `ReaderT`.
Instance details Defined in Sound.Osc.Transport.Monad Methods sendPacket :: Packet -> ReaderT t io () Source #

class Monad m => RecvOsc m where Source #

Receiver monad.

Methods

recvPacket :: m Packet Source #

Receive and decode an Osc packet.

#### Instances

Instances details

(Transport t, MonadIO io) => RecvOsc (ReaderT t io) Source # | `RecvOsc` over `ReaderT`.
Instance details Defined in Sound.Osc.Transport.Monad Methods recvPacket :: ReaderT t io Packet Source #

class (SendOsc m, RecvOsc m) => DuplexOsc m Source #

`DuplexOsc` is the union of `SendOsc` and `RecvOsc`.

#### Instances

Instances details

(Transport t, MonadIO io) => DuplexOsc (ReaderT t io) Source # | `DuplexOsc` over `ReaderT`.
Instance details Defined in Sound.Osc.Transport.Monad

class (DuplexOsc m, MonadIO m) => Transport m Source #

`Transport` is `DuplexOsc` with a `MonadIO` constraint.

#### Instances

Instances details

(Transport t, MonadIO io) => Transport (ReaderT t io) Source # | `Transport` over `ReaderT`.
Instance details Defined in Sound.Osc.Transport.Monad

type Connection t a = ReaderT t IO a Source #

Transport connection.

withTransport :: Transport t => IO t -> Connection t r -> IO r Source #

Bracket Open Sound Control communication.

withTransport_ :: Transport t => IO t -> Connection t r -> IO () Source #

`void` of `withTransport`.

# Send

sendMessage :: SendOsc m => Message -> m () Source #

Type restricted synonym for `sendOsc`.

sendBundle :: SendOsc m => Bundle -> m () Source #

Type restricted synonym for `sendOsc`.

# Receive

recvBundle :: RecvOsc m => m Bundle Source #

Variant of `recvPacket` that runs `packet_to_bundle`.

recvMessage :: RecvOsc m => m (Maybe Message) Source #

Variant of `recvPacket` that runs `packet_to_message`.

recvMessage_err :: RecvOsc m => m Message Source #

Erroring variant.

recvMessages :: RecvOsc m => m [Message] Source #

Variant of `recvPacket` that runs `packetMessages`.

# Wait

waitUntil :: RecvOsc m => (Packet -> Bool) -> m Packet Source #

Wait for a `Packet` where the supplied predicate is `True`, discarding intervening packets.

waitFor :: RecvOsc m => (Packet -> Maybe a) -> m a Source #

Wait for a `Packet` where the supplied function does not give `Nothing`, discarding intervening packets.

waitImmediate :: RecvOsc m => m Packet Source #

`waitUntil` `packet_is_immediate`.

waitMessage :: RecvOsc m => m Message Source #

`waitFor` `packet_to_message`, ie. an incoming `Message` or immediate mode `Bundle` with one element.

waitAddress :: RecvOsc m => Address_Pattern -> m Packet Source #

A `waitFor` for variant using `packet_has_address` to match on the `Address_Pattern` of incoming `Packets`.

waitReply :: RecvOsc m => Address_Pattern -> m Message Source #

Variant on `waitAddress` that returns matching `Message`.

waitDatum :: RecvOsc m => Address_Pattern -> m [Datum] Source #

Variant of `waitReply` that runs `messageDatum`.