TrieMap-2.0.3: 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

Methods

toRep :: a -> Rep aSource

Instances

Repr Bool 
Repr Char 
Repr Double 
Repr Float 
Repr Int 
Repr Int8 
Repr Int16 
Repr Int32 
Repr Int64 
Repr Integer 
Repr Ordering 
Repr Word 
Repr Word8 
Repr Word16 
Repr Word32 
Repr Word64 
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 
Repr ByteString 
Repr a => Repr [a] 
Integral a[akDh] => Repr (Ratio a[akDh]) 
Repr (Maybe a[a2zs]) 
Repr (Tree a[akCC]) 
Repr a => Repr (Seq a) 
Repr a => Repr (Set a) 
Repr a => Repr (Vector a) 
Repr (Vector Char) 
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word) 
Repr (Vector Word8) 
Repr (Vector Word16) 
Repr (Vector Word32) 
Repr (Vector Word64) 
Repr (Vector Char) 
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word) 
Repr (Vector Word8) 
Repr (Vector Word16) 
Repr (Vector Word32) 
Repr (Vector Word64) 
Repr (Vector Char) 
Repr (Vector Int) 
Repr (Vector Int8) 
Repr (Vector Int16) 
Repr (Vector Int32) 
Repr (Vector Int64) 
Repr (Vector Word) 
Repr (Vector Word8) 
Repr (Vector Word16) 
Repr (Vector Word32) 
Repr (Vector Word64) 
Repr k => Repr (Key k) 
Repr (Either a[ad8O] b[ad8N]) 
(Repr a, Repr b) => Repr (a, b) 
(Repr k, Repr a) => Repr (Map k a) 
(Repr a, Repr b, Repr c) => Repr (a, b, c) 
(Repr a, Repr b, Repr c, Repr d) => Repr (a, b, c, d) 
(Repr a, Repr b, Repr c, Repr d, Repr e) => Repr (a, b, c, d, e) 
(Repr a, Repr b, Repr c, Repr d, Repr e, Repr f) => Repr (a, b, c, d, e, f) 
(Repr a, Repr b, Repr c, Repr d, Repr e, Repr f, Repr g) => Repr (a, b, c, d, e, f, g) 
(Repr a, Repr b, Repr c, Repr d, Repr e, Repr f, Repr g, Repr h) => Repr (a, b, c, d, e, f, g, h) 
(Repr a, Repr b, Repr c, Repr d, Repr e, Repr f, Repr g, Repr h, Repr i) => Repr (a, b, c, d, e, f, g, h, i) 
(Repr a, Repr b, Repr c, Repr d, Repr e, Repr f, Repr g, Repr h, Repr i, Repr j) => 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.