TrieMap-4.0.1: Automatic type inference of generalized tries with Template Haskell.

Data.TrieMap.Representation

Synopsis

Documentation

class Repr a whereSource

The Repr type class denotes that a type can be decomposed to a representation built out of pieces for which the TrieKey class defines a generalized trie structure.

It is required that, if (Repr a, Eq a), and x, y :: a, then x == y if and only if toRep x == toRep y. It is typically the case that compare x y == compare (toRep x) (toRep y), as well, but this is not strictly required. (It is, however, the case for all instances built into the package.)

As an additional note, the Key modifier is used for "bootstrapping" Repr instances, allowing a type to be used in its own Repr definition when wrapped in a Key modifier.

Associated Types

type Rep a Source

type RepList a Source

Methods

toRep :: a -> Rep aSource

toRepList :: [a] -> RepList aSource

Instances

Repr Bool 
Repr Char
Rep Char = Word
Repr Double 
Repr Float 
Repr Int

Rep Int = Word, by way of a careful translation of their domains to avoid overflow.

Repr Int8 
Repr Int16 
Repr Int32 
Repr Int64 
Repr Integer 
Repr Ordering 
Repr Word 
Repr Word8
Rep Word8 = Word
Repr Word16
Rep Word16 = Word
Repr Word32
Rep Word32 = Word
Repr Word64
Rep Word64 = (Word, Word)
Repr () 
Repr CChar 
Repr CSChar 
Repr CUChar 
Repr CShort 
Repr CUShort 
Repr CInt 
Repr CUInt 
Repr CLong 
Repr CULong 
Repr CLLong 
Repr CULLong 
Repr CFloat 
Repr CDouble 
Repr CPtrdiff 
Repr CSize 
Repr CWchar 
Repr CSigAtomic 
Repr CClock 
Repr CTime 
Repr ByteString
Rep ByteString = Rep (Vector Word8)
Repr a => Repr [a]

Uses the RepList instance of a. (This allows for efficient and automatic implementations of e.g. Rep String.)

Integral a => Repr (Ratio a) 
Repr (Maybe a) 
Repr (Tree a) 
Repr a => Repr (Seq a) 
Repr a => Repr (Set a) 
Repr a => Repr (Vector a) 
Repr (Vector Bool) 
Repr (Vector Char) 
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word8) 
Repr (Vector Word16) 
Repr (Vector Word32) 
Repr (Vector Char) 
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word8) 
Repr (Vector Word16) 
Repr (Vector Word32) 
Repr (Vector Char)
Rep (Vector Char) = Vector Word
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word) 
Repr (Vector Word8)

Rep (Vector Word8) = Vector Word, by packing multiple Word8s into each Word for space efficiency.

Repr (Vector Word16)

Rep (Vector Word16) = Vector Word, by packing multiple Word16s into each Word for space efficiency.

Repr (Vector Word32) 
Repr (Vector Word64)

Rep (Vector Word64) = Vector Word, by viewing each Word64 as two Words.

Repr k => Repr (Key k) 
Repr (Either a b) 
Repr (a, b) 
(Repr k, Repr a) => Repr (Map k a) 
Repr (a, b, c) 
Repr (a, b, c, d) 
Repr (a, b, c, d, e) 
Repr (a, b, c, d, e, f) 
Repr (a, b, c, d, e, f, g) 
Repr (a, b, c, d, e, f, g, h) 
Repr (a, b, c, d, e, f, g, h, i) 
Repr (a, b, c, d, e, f, g, h, i, j) 

genRepr :: Name -> Q [Dec]Source

Given the name of a type constructor, automatically generates an efficient Repr instance. If you have several mutually dependent (or even mutually recursive) types, genRepr will construct instances for all of them.

genRepr guarantees that any instances it generates are consistent with the ordering that would be generated by deriving (Ord) in the data declaration. That is, if genRepr generates an instance Repr a, then it is guaranteed that if x, y :: a, and a has a derived Ord instance, then compare x y == compare (toRep x) (toRep y).

genOptRepr :: Name -> Q [Dec]Source

Given the name of a type constructor, automatically generates an efficient Repr instance. If you have several mutually dependent (or even mutually recursive) types, genOptRepr will construct instances for all of them. The instance generated by genOptRepr may, in some cases, be more efficient than the instance generated by genRepr -- in particular, arguments common to several constructors may be factored out, reducing the complexity of the associated TrieKey instance, but leaving an ordering inconsistent with Ord.

Therefore, genOptRepr guarantees that any instances it generates are consistent with the ordering that would be generated by deriving (Eq) in the data declaration. That is, if genOptRepr generates an instance Repr a, then it is guaranteed that if x, y :: a, and a has a derived Eq instance, then (x == y) == (toRep x == toRep y).

genOrdRepr :: Name -> Q [Dec]Source

Given a type with an associated Ord instance, generates a representation that will cause its TMap implementation to be essentially equivalent to Data.Map.