System.TPFS.Device
Description
Defines a readable and writable random-access device class, and some supporting classes.
- type Address = Word64
- class (Functor m, Applicative m, Monad m, Interleave m) => Device m h where
- dGet :: Integral i => h -> Address -> i -> m ByteString
- dPut :: h -> Address -> ByteString -> m ()
- class Monad m => Interleave m where
- interleave :: m a -> m a
- class Binary a => BinarySize a where
- binarySize :: a -> (Integer, Integer)
Documentation
class (Functor m, Applicative m, Monad m, Interleave m) => Device m h whereSource
Methods
Arguments
| :: Integral i | |
| => h | The device handle. |
| -> Address | The address to read from. |
| -> i | The number of bytes to read. |
| -> m ByteString | The read bytestring. If read past EOF, the remaining bytes should be nulls. |
Reads bytes from the device. It should never return less than the requested number of bytes.
Arguments
| :: h | The device handle. |
| -> Address | Address to write at. |
| -> ByteString | String to write. |
| -> m () |
Writes bytes to the device.
class Monad m => Interleave m whereSource
Only necessary for IO -- the default implementation should be sufficient for most monads.
Methods
interleave :: m a -> m aSource
Instances
class Binary a => BinarySize a whereSource
Methods
binarySize :: a -> (Integer, Integer)Source
Returns a minimum and maximum size (in bytes) for an encoded object of this type. The actual value of the object itself should be discarded; this should be a constant.
Instances