Copyright | (c) Christian Gram Kalhauge 2017 |
---|---|
License | MIT |
Maintainer | kalhuage@cs.ucla.edu |
Safe Haskell | None |
Language | Haskell2010 |
This module contains utilities missing not in other libraries.
- newtype SizedList w a = SizedList {
- unSizedList :: [a]
- listSize :: Num w => SizedList w a -> w
- newtype SizedByteString w = SizedByteString {}
- byteStringSize :: Num w => SizedByteString w -> w
- type SizedList16 = SizedList Word16
- type SizedByteString32 = SizedByteString Word32
- type SizedByteString16 = SizedByteString Word16
- sizedByteStringFromText :: Text -> SizedByteString w
- sizedByteStringToText :: SizedByteString w -> Either UnicodeException Text
- tryDecode :: ByteString -> Either UnicodeException Text
- newtype BitSet w a = BitSet {}
- class (Eq a, Ord a) => Enumish a where
- type BitSet16 = BitSet Word16
- trd :: (a, b, c) -> c
Sized Data Structures
These data structures enables binary reading and writing of lists and byte strings that are prepended with the number of elements to read or write.
newtype SizedList w a Source #
SizedList is a binary type, that reads a list of elements. It first reads a
length N of type w
and then N items of type a
.
SizedList | |
|
Functor (SizedList w) Source # | |
Foldable (SizedList w) Source # | |
Traversable (SizedList w) Source # | |
Eq a => Eq (SizedList w a) Source # | |
Ord a => Ord (SizedList w a) Source # | |
Show a => Show (SizedList w a) Source # | |
(Binary w, Integral w, Binary a) => Binary (SizedList w a) Source # | |
NFData a => NFData (SizedList w a) Source # | |
newtype SizedByteString w Source #
A byte string with a size w.
Eq (SizedByteString w) Source # | |
Ord (SizedByteString w) Source # | |
Show (SizedByteString w) Source # | |
IsString (SizedByteString w) Source # | |
(Binary w, Integral w) => Binary (SizedByteString w) Source # | |
NFData (SizedByteString w) Source # | |
byteStringSize :: Num w => SizedByteString w -> w Source #
Get the size of a SizedByteString
Specific sizes
type SizedList16 = SizedList Word16 Source #
A sized list using a 16 bit word as length
type SizedByteString32 = SizedByteString Word32 Source #
A sized bytestring using a 32 bit word as length
type SizedByteString16 = SizedByteString Word16 Source #
A sized bytestring using a 16 bit word as length
sizedByteStringFromText :: Text -> SizedByteString w Source #
Convert a Sized bytestring from Utf8 Text.
sizedByteStringToText :: SizedByteString w -> Either UnicodeException Text Source #
Convert a Sized bytestring to Utf8 Text.
Bit Set
A bit set is a set where each element is represented a bit in a word. This
section also defines the Enumish
type class. It is different than a Enum
in that the integers they represent does not have to be subsequent.
A bit set of size w
class (Eq a, Ord a) => Enumish a where Source #
An Enumish value, all maps to a number, but not all integers maps to a enumsish value. There is no guarantee that the integers will be subsequent.