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.
Synopsis
- 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 SizedList8 = SizedList Word8
- 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 | |
|
Instances
newtype SizedByteString w Source #
A byte string with a size w.
Instances
byteStringSize :: Num w => SizedByteString w -> w Source #
Get the size of a SizedByteString
Specific sizes
type SizedList8 = SizedList Word8 Source #
A sized list using a 8 bit word as length
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
Instances
Eq a => Eq (BitSet w a) Source # | |
Ord a => Ord (BitSet w a) Source # | |
Show a => Show (BitSet w a) Source # | |
(Show w, Bits w, Binary w, Enumish a) => Binary (BitSet w a) Source # | |
NFData a => NFData (BitSet w a) Source # | |
Defined in Language.JVM.Utils |
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.
inOrder :: [(Int, a)] Source #
The only needed implementation is a list of integer-enum pairs in ascending order, corresponding to their integer value.
fromEnumish :: a -> Int Source #
Instances
Enumish PAccessFlag Source # | |
Defined in Language.JVM.AccessFlag inOrder :: [(Int, PAccessFlag)] Source # fromEnumish :: PAccessFlag -> Int Source # | |
Enumish FAccessFlag Source # | |
Defined in Language.JVM.AccessFlag inOrder :: [(Int, FAccessFlag)] Source # fromEnumish :: FAccessFlag -> Int Source # | |
Enumish ICAccessFlag Source # | |
Defined in Language.JVM.AccessFlag inOrder :: [(Int, ICAccessFlag)] Source # fromEnumish :: ICAccessFlag -> Int Source # | |
Enumish CAccessFlag Source # | |
Defined in Language.JVM.AccessFlag inOrder :: [(Int, CAccessFlag)] Source # fromEnumish :: CAccessFlag -> Int Source # | |
Enumish MAccessFlag Source # | |
Defined in Language.JVM.AccessFlag inOrder :: [(Int, MAccessFlag)] Source # fromEnumish :: MAccessFlag -> Int Source # |