Safe Haskell | None |
---|---|

Language | Haskell2010 |

Streamline exports a monad that, given an uniform IO target, emulates character tream IO using high performance block IO.

- data Streamline m a
- withClient :: MonadIO m => (IP -> Int -> Streamline m a) -> BoundedPort -> m a
- withServer :: MonadIO m => Streamline m a -> IP -> Int -> m a
- withTarget :: (MonadIO m, UniformIO a) => Streamline m b -> a -> m b
- send :: MonadIO m => ByteString -> Streamline m ()
- receiveLine :: MonadIO m => Streamline m ByteString
- lazyRecieveLine :: MonadIO m => Streamline m [ByteString]
- lazyReceiveN :: (Functor m, MonadIO m) => Int -> Streamline m [ByteString]
- startTls :: MonadIO m => TlsSettings -> Streamline m ()
- runAttoparsec :: MonadIO m => Parser a -> Streamline m (Either String a)
- runAttoparsecAndReturn :: MonadIO m => Parser a -> Streamline m (ByteString, Either String a)
- isSecure :: Monad m => Streamline m Bool
- setTimeout :: Monad m => Int -> Streamline m ()
- setEcho :: Monad m => Bool -> Streamline m ()

# Documentation

data Streamline m a Source #

Monad that emulates character stream IO over block IO.

MonadTrans Streamline Source # | |

Monad m => Monad (Streamline m) Source # | |

Monad m => Functor (Streamline m) Source # | |

(Functor m, Monad m) => Applicative (Streamline m) Source # | |

MonadIO m => MonadIO (Streamline m) Source # | |

withClient :: MonadIO m => (IP -> Int -> Streamline m a) -> BoundedPort -> m a Source #

withClient f boundPort

Accepts a connection at the bound port, runs f and closes the connection.

withServer :: MonadIO m => Streamline m a -> IP -> Int -> m a Source #

withServer f serverIP port

Connects to the given server port, runs f, and closes the connection.

withTarget :: (MonadIO m, UniformIO a) => Streamline m b -> a -> m b Source #

withTarget f someIO

Runs f wrapped on a Streamline monad that does IO on nomeIO.

send :: MonadIO m => ByteString -> Streamline m () Source #

Sends data over the streamlines an IO target.

receiveLine :: MonadIO m => Streamline m ByteString Source #

Receives a line from the streamlined IO target.

lazyRecieveLine :: MonadIO m => Streamline m [ByteString] Source #

Receives a line from the streamlined IO target, but breaks the line on reasonably sized chuncks, and reads them lazyly, so that IO can be done in constant memory space.

lazyReceiveN :: (Functor m, MonadIO m) => Int -> Streamline m [ByteString] Source #

lazyReceiveN n Receives n bytes of data from the streamlined IO target, but breaks the data on reasonably sized chuncks, and reads them lazyly, so that IO can be done in constant memory space.

startTls :: MonadIO m => TlsSettings -> Streamline m () Source #

Wraps the streamlined IO target on TLS, streamlining the new wrapper afterwads.

runAttoparsec :: MonadIO m => Parser a -> Streamline m (Either String a) Source #

Runs an Attoparsec parser over the data read from the streamlined IO target. Returning the parser result.

runAttoparsecAndReturn :: MonadIO m => Parser a -> Streamline m (ByteString, Either String a) Source #

Runs an Attoparsec parser over the data read from the streamlined IO target. Returns both the parser result and the string consumed by it.

isSecure :: Monad m => Streamline m Bool Source #

Indicates whether transport layer security is being used.

setTimeout :: Monad m => Int -> Streamline m () Source #

Sets the timeout for the streamlined IO target.