Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internal functions
Synopsis
- encodeWord32 :: Word32 -> ByteString
- decodeWord32 :: ByteString -> Word32
- encodeEnum32 :: Enum a => a -> ByteString
- decodeNum32 :: Num a => ByteString -> a
- encodeWord16 :: Word16 -> ByteString
- decodeWord16 :: ByteString -> Word16
- encodeEnum16 :: Enum a => a -> ByteString
- decodeNum16 :: Num a => ByteString -> a
- prependLength :: [ByteString] -> [ByteString]
- mapIOException :: Exception e => (IOException -> e) -> IO a -> IO a
- tryIO :: MonadIO m => IO a -> m (Either IOException a)
- tryToEnum :: (Enum a, Bounded a) => Int -> Maybe a
- timeoutMaybe :: Exception e => Maybe Int -> e -> IO a -> IO a
- asyncWhenCancelled :: (a -> IO ()) -> IO a -> IO a
- void :: Monad m => m a -> m ()
- forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId
- tlog :: MonadIO m => String -> m ()
Encoders/decoders
encodeWord32 :: Word32 -> ByteString Source #
Serialize 32-bit to network byte order
decodeWord32 :: ByteString -> Word32 Source #
Deserialize 32-bit from network byte order Throws an IO exception if this is not exactly 32 bits.
encodeEnum32 :: Enum a => a -> ByteString Source #
Encode an Enum in 32 bits by encoding its signed Int equivalent (beware of truncation, an Enum may contain more than 2^32 points).
decodeNum32 :: Num a => ByteString -> a Source #
Decode any Num type from 32 bits by using fromIntegral to convert from a Word32.
encodeWord16 :: Word16 -> ByteString Source #
Serialize 16-bit to network byte order
decodeWord16 :: ByteString -> Word16 Source #
Deserialize 16-bit from network byte order Throws an IO exception if this is not exactly 16 bits.
encodeEnum16 :: Enum a => a -> ByteString Source #
Encode an Enum in 16 bits by encoding its signed Int equivalent (beware of truncation, an Enum may contain more than 2^16 points).
decodeNum16 :: Num a => ByteString -> a Source #
Decode any Num type from 16 bits by using fromIntegral to convert from a Word16.
prependLength :: [ByteString] -> [ByteString] Source #
Prepend a list of bytestrings with their total length Will be an exception in case of overflow: the sum of the lengths of the ByteStrings overflows Int, or that sum overflows Word32.
Miscellaneous abstractions
mapIOException :: Exception e => (IOException -> e) -> IO a -> IO a Source #
Translate exceptions that arise in IO computations
tryIO :: MonadIO m => IO a -> m (Either IOException a) Source #
Like try
, but lifted and specialized to IOExceptions
timeoutMaybe :: Exception e => Maybe Int -> e -> IO a -> IO a Source #
If the timeout value is not Nothing, wrap the given computation with a timeout and it if times out throw the specified exception. Identity otherwise.
asyncWhenCancelled :: (a -> IO ()) -> IO a -> IO a Source #
asyncWhenCancelled g f
runs f in a separate thread and waits for it
to complete. If f throws an exception we catch it and rethrow it in the
current thread. If the current thread is interrupted before f completes,
we run the specified clean up handler (if f throws an exception we assume
that no cleanup is necessary).
Replicated functionality from "base"
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId Source #
This was introduced in "base" some time after 7.0.4