| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Flat.Instances.Base
Contents
Description
Flat instances for the base library
Orphan instances
| Flat Bool Source # | One bit is plenty for a Bool.
|
| Flat Char Source # | Char's are mapped to Word32 and then encoded. For ascii characters, the encoding is standard ascii.
For unicode characters, the encoding is non standard.
|
| Flat Double Source # | Doubles are encoded as standard IEEE binary64 values: IEEE_754_binary64 ≡ IEEE_754_binary64 {sign :: Sign,
exponent :: MostSignificantFirst Bits11,
fraction :: MostSignificantFirst Bits52}
|
| Flat Float Source # | Floats are encoded as standard IEEE binary32 values: IEEE_754_binary32 ≡ IEEE_754_binary32 {sign :: Sign,
exponent :: MostSignificantFirst Bits8,
fraction :: MostSignificantFirst Bits23}
|
| Flat Int Source # | Integer, Int, Int16, Int32 and Int64 are defined as the ZigZag encoded version of the equivalent unsigned Word: Int ≡ Int (ZigZag Word) Int64 ≡ Int64 (ZigZag Word64) Int32 ≡ Int32 (ZigZag Word32) Int16 ≡ Int16 (ZigZag Word16) Int8 ≡ Int8 (ZigZag Word8) ZigZag a ≡ ZigZag a ZigZag encoding alternates between positive and negative numbers, so that numbers whose absolute value is small can be encoded efficiently:
|
| Flat Int8 Source # |
|
| Flat Int16 Source # |
equivalent to 0b1111111111111111
equivalent to 0b1111111111111110 |
| Flat Int32 Source # |
|
| Flat Int64 Source # |
|
| Flat Integer Source # | Integers are encoded just as the fixed size Ints.
|
| Flat Natural Source # | Naturals are encoded just as the fixed size Words.
|
| Flat Word Source # | Natural, Word, Word16, Word32 and Word64 are encoded as a non empty list of 7 bits chunks (least significant chunk first and most significant bit first in every chunk). Words are always encoded in a whole number of bytes, as every chunk is 8 bits long (1 bit for the List constructor, plus 7 bits for the value). The actual definition is: Word64 ≡ Word64 Word
Word32 ≡ Word32 Word
Word16 ≡ Word16 Word
Word ≡ Word (LeastSignificantFirst (NonEmptyList (MostSignificantFirst Word7)))
LeastSignificantFirst a ≡ LeastSignificantFirst a
NonEmptyList a ≡ Elem a
| Cons a (NonEmptyList a)
MostSignificantFirst a ≡ MostSignificantFirst a
Word7 ≡ V0
| V1
| V2
...
| V127
Values between as 0 and 127 fit in a single byte. 127 (0b1111111) is represented as Elem V127 and encoded as: Elem=0 127=1111111
254 (0b11111110) is represented as Cons V126 (Elem V1) (254=128+126) and encoded as: Cons=1 V126=1111110 (Elem=0 V1=0000001):
Another example, 32768 (Ob1000000000000000 = 0000010 0000000 0000000):
As this is a variable length encoding, values are encoded in the same way, whatever their type:
|
| Flat Word8 Source # | Word8 always take 8 bits.
|
| Flat Word16 Source # | |
| Flat Word32 Source # | |
| Flat Word64 Source # | |
| Flat () Source # | `()`, as all data types with a single constructor, has a zero-length encoding.
|
| Flat All Source # | Since: 0.4.4 |
| Flat Any Source # | Since: 0.4.4 |
| Flat [Char] Source # | For better encoding/decoding performance, it is useful to declare instances of concrete list types, such as [Char].
|
| Flat a => Flat [a] Source # |
|
| Flat a => Flat (Maybe a) Source # |
|
| (Integral a, Flat a) => Flat (Ratio a) Source # | Ratios are encoded as tuples of (numerator,denominator)
|
| Flat a => Flat (Complex a) Source # |
|
| Flat (Fixed a) Source # |
|
| Flat a => Flat (Min a) Source # | Since: 0.4.4 |
| Flat a => Flat (Max a) Source # | Since: 0.4.4 |
| Flat a => Flat (First a) Source # | Since: 0.4.4 |
| Flat a => Flat (Last a) Source # | Since: 0.4.4 |
| Flat a => Flat (Option a) Source # | Since: 0.4.4 |
| Flat a => Flat (Identity a) Source # | Since: 0.4.4 |
| Flat a => Flat (Dual a) Source # | Since: 0.4.4 |
| Flat a => Flat (Sum a) Source # | Since: 0.4.4 |
| Flat a => Flat (Product a) Source # | Since: 0.4.4 |
| Flat a => Flat (NonEmpty a) Source # |
|
| (Flat a, Flat b) => Flat (Either a b) Source # |
|
| (Flat a, Flat b) => Flat (a, b) Source # | Tuples are supported up to 7 elements.
"7 elements tuples ought to be enough for anybody" (Bill Gates - apocryphal)
tst (1::Int,"2","3","4","5","6","7","8") ...error |
| (Flat a, Flat b, Flat c) => Flat (a, b, c) Source # | |
| Flat (f a) => Flat (Alt f a) Source # |
Since: 0.4.4 |
| (Flat a, Flat b, Flat c, Flat d) => Flat (a, b, c, d) Source # | |
| (Flat a, Flat b, Flat c, Flat d, Flat e) => Flat (a, b, c, d, e) Source # | |
| (Flat a, Flat b, Flat c, Flat d, Flat e, Flat f) => Flat (a, b, c, d, e, f) Source # | |
| (Flat a, Flat b, Flat c, Flat d, Flat e, Flat f, Flat g) => Flat (a, b, c, d, e, f, g) Source # | |