stable-tree-0.7.0: Trees whose branches are resistant to change

CopyrightJeremy Groven
LicenseBSD3
Safe HaskellNone
LanguageHaskell2010

Data.StableTree.Key

Description

Tools for working with StableTree keys.

Synopsis

Documentation

data Key t k Source

A wrapper for keys; this has an ephemeral t that will be either Terminal or Nonterminal depending on the result of byte k.

Instances

Eq k => Eq (Key t k) 
Ord k => Ord (Key t k) 
Show k => Show (Key t k) 

data SomeKey k Source

A sum type to contain either a Terminal or a Nonterminal Key

Instances

Eq k => Eq (SomeKey k) 
Ord k => Ord (SomeKey k) 
Show k => Show (SomeKey k) 

class StableKey k where Source

Type class for StableTree keys

Methods

hash :: k -> Word8 Source

Get the "hash" of a key; this is just a single-byte, of which only four bits are really used. Just enough to allow one key in 16 to be Terminal

Instances

StableKey Bool 
StableKey Char 
StableKey Double 
StableKey Float 
StableKey Int 
StableKey Int8 
StableKey Int16 
StableKey Int32 
StableKey Int64 
StableKey Integer 
StableKey Ordering 
StableKey Word 
StableKey Word8 
StableKey Word16 
StableKey Word32 
StableKey Word64 
StableKey ByteString 
StableKey ByteString 
StableKey IntSet 
Serialize a => StableKey [a] 
(Serialize a, Integral a) => StableKey (Ratio a) 
Serialize a => StableKey (Maybe a) 
Serialize e => StableKey (IntMap e) 
(Ord a, Serialize a) => StableKey (Set a) 
Serialize e => StableKey (Tree e) 
Serialize e => StableKey (Seq e) 
(Serialize a, Serialize b) => StableKey (Either a b) 
(Serialize a, Serialize b) => StableKey (a, b) 
(Ord k, Serialize k, Serialize e) => StableKey (Map k e) 
(Serialize a, Serialize b, Serialize c) => StableKey (a, b, c) 
(Serialize a, Serialize b, Serialize c, Serialize d) => StableKey (a, b, c, d) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e) => StableKey (a, b, c, d, e) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f) => StableKey (a, b, c, d, e, f) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g) => StableKey (a, b, c, d, e, f, g) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h) => StableKey (a, b, c, d, e, f, g, h) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h, Serialize i) => StableKey (a, b, c, d, e, f, g, h, i) 
(Serialize a, Serialize b, Serialize c, Serialize d, Serialize e, Serialize f, Serialize g, Serialize h, Serialize i, Serialize j) => StableKey (a, b, c, d, e, f, g, h, i, j) 

data Terminal Source

Used to indicate that a Key is terminal

data Nonterminal Source

Used to indicate that a Key is not terminal

wrap :: StableKey k => k -> SomeKey k Source

Do the magic of wrapping up a key into a SomeKey

unwrap :: SomeKey k -> k Source

Extract the original key from a wrapped one

hashBs :: ByteString -> Word8 Source

Calculate a single-byte hash for a ByteString