-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | File-backed recursive data structures. -- -- This package is a library for datatype-generic disk serialization. It -- provides a file abstraction that uses multi-version concurrency -- control to support transaction-aware isolation for multi-threaded -- access. The base library comes with a collection of datatypes to -- provide sets and key-value stores with different properties. @package fixfile @version 0.1.0.0 -- | A FixFile is file for storing recursive data. The file supports -- MVCC through an append-only file. -- -- In order to eliminate distinctions between data structures that are -- file-backed versus in-memory, this library makes heavy use of lazy IO. -- Transactions are used to ensure safety of the unsafe IO. -- -- The data structures used by a FixFile should not be recursive -- directly, but should have instances of Foldable, -- Traversable, and Binary and should be structured such -- that the fixed point of the data type is recursive. -- -- There is also the concept of the Root data of a FixFile. -- This can be used as a kind of header for a FixFile that can allow -- several recursive data structures to be modified in a single -- transaction. module Data.FixFile -- | Fixed is a typeclass for representing the fixed point of a -- Functor. A well-behaved instance of Fixed should not -- change the shape of the underlying Functor. -- -- In other words, the following should always be true: outf -- (inf x) == x class Fixed g inf :: Fixed g => f (g f) -> g f outf :: Fixed g => g f -> f (g f) -- | Fix is a type for creating an in-memory representation of the -- fixed point of a Functor. newtype Fix f InF :: f (Fix f) -> Fix f [outF] :: Fix f -> f (Fix f) -- | Stored is a fixed-point combinator of f in Transaction -- s. data Stored s f -- | CataAlg is a catamorphism F-Algebra. type CataAlg f a = f a -> a -- | cata applies a CataAlg over a fixed point of a -- Functor. cata :: (Functor f, Fixed g) => CataAlg f a -> g f -> a -- | AnaAlg is an anamorpism F-Algebra. type AnaAlg f a = a -> f a -- | ana applies an AnaAlg over an argument to produce a fixed-point -- of a Functor. ana :: (Functor f, Fixed g) => AnaAlg f a -> a -> g f -- | ParaAlg is a paramorphism F-Algebra. type ParaAlg g f a = f (g f, a) -> a -- | para applies a ParaAlg over a fixed point of a -- Functor. para :: (Functor f, Fixed g) => ParaAlg g f a -> g f -> a -- | iso maps from a fixed point of a Functor to a different -- fixed point of the same Functor. For any two well-behaved -- instances of Fixed, the shape of the Functor should -- remain unchanged. iso :: (Functor f, Fixed g, Fixed h) => g f -> h f -- | A Root datastructure acts as a kind of header that can contain -- one or more Refs to different recursive structures. It takes -- one argument, which has the kind of ((* -> *) -> *). -- This argument should be either an instance of Fixed or a -- Ptr. If it is an instance of Fixed, then the Root -- can contain recursive data structures. If it is passed Ptr as -- an argument, then the Root will contain a non-recursive -- structure, but can be serialized. class Root (r :: ((* -> *) -> *) -> *) -- | Deserialize r Ptr inside a -- Transaction. readRoot :: Root r => r Ptr -> Transaction r' s (r (Stored s)) -- | Serialize r Ptr inside a Transaction. -- This will result in | changes to any recursive structures to be -- written as well. writeRoot :: Root r => r (Stored s) -> Transaction r' s (r Ptr) -- | iso, but applied to an instance of Root. rootIso :: (Root r, Fixed g, Fixed h) => r g -> r h -- | A Ptr points to a location in a FixFile and has a -- phantom type for a Functor f. A Root expects an -- argument that resembles a Fixed, but we can pass it a -- Ptr instead. This is not a well-formed Fixed because it -- can't be unpacked into f (Ptr f). -- -- But, it can be serialized, which allows a Root object that -- takes this as an argument to be serialized. data Ptr (f :: * -> *) -- | A Ref is a reference to a Functor f in the -- Fixed instance of g. -- -- This is an instance of Root and acts to bridge between the -- Root and the recursively defined data structure that is -- (g f). data Ref (f :: * -> *) (g :: (* -> *) -> *) Ref :: g f -> Ref [deRef] :: Ref -> g f -- | Lens for accessing the value stored in a Ref ref :: Lens' (Ref f g) (g f) -- | A FixFile is a handle for accessing a file-backed recursive -- data structure. r is the Root object stored in the -- FixFile. data FixFile r -- | Create a FixFile, using Fix f as the initial -- structure to store at the location described by FilePath. createFixFile :: (Root r, Binary (r Ptr), Typeable r) => r Fix -> FilePath -> IO (FixFile r) -- | Create a FixFile, using Fix f as the initial -- structure to store at the location described by FilePath and -- using the Handle to the file to be created. createFixFileHandle :: (Root r, Binary (r Ptr), Typeable r) => r Fix -> FilePath -> Handle -> IO (FixFile r) -- | Open a FixFile from the file described by FilePath. openFixFile :: Binary (r Ptr) => FilePath -> IO (FixFile r) -- | Open a FixFile from the file described by FilePath and -- using the Handle to the file. openFixFileHandle :: Binary (r Ptr) => FilePath -> Handle -> IO (FixFile r) -- | Close a FixFile. This can potentially cause errors on data that -- is lazily being read from a Transaction. closeFixFile :: FixFile r -> IO () -- | Because a FixFile is backed by an append-only file, there is a -- periodic need to vacuum the file to garbage collect data that -- is no longer referenced from the root. This task operates on a -- temporary file that then replaces the file that backs FixFile. -- -- The memory usage of this operation scales with the recursive depth of -- the structure stored in the file. vacuum :: (Root r, Binary (r Ptr), Typeable r) => FixFile r -> IO () -- | A Transaction is an isolated execution of a read or update -- operation on the root object stored in a FixFile. r is -- the Root data that is stored by the FixFile. s -- is a phantom type used to isolate Stored values to the -- transaction where they are run. data Transaction r s a -- | The preferred way to modify the root object of a FixFile is by -- using alterT. It applies a function that takes the root object -- as a Stored s f and returns the new -- desired head of the same type. alterT :: (tr ~ Transaction (Ref f) s, Traversable f, Binary (f (Ptr f))) => (Stored s f -> Stored s f) -> tr () -- | The preferred way to read from a FixFile is to use -- lookupT. It applies a function that takes a Stored s -- f and returns a value. lookupT :: (tr ~ Transaction (Ref f) s, Traversable f, Binary (f (Ptr f))) => (Stored s f -> a) -> tr a -- | Perform a read transaction on a FixFile. This transaction -- cannot modify the root object stored in the file. The returned value -- is lazily evaluated, but will always correspond to the root object at -- the start of the transaction. readTransaction :: Root r => FixFile r -> (forall s. Transaction r s a) -> IO a -- | Perform a write transaction on a FixFile. This operation -- differs from the readTransaction in that the root object stored in the -- file can potentially be updated by this Transaction. writeTransaction :: (Root r, Binary (r Ptr), Typeable r) => FixFile r -> (forall s. Transaction r s a) -> IO a -- | Perform a Transaction on a part of the root object. subTransaction :: Lens' (r (Stored s)) (r' (Stored s)) -> Transaction r' s a -> Transaction r s a -- | Get the full datastructure from the transaction as a Fix -- f. getFull :: Functor f => Transaction (Ref f) s (Fix f) instance GHC.Generics.Selector Data.FixFile.S1_0_0Ref instance GHC.Generics.Constructor Data.FixFile.C1_0Ref instance GHC.Generics.Datatype Data.FixFile.D1Ref instance GHC.Generics.Constructor Data.FixFile.C1_0Ptr instance GHC.Generics.Datatype Data.FixFile.D1Ptr instance GHC.Generics.Generic (Data.FixFile.Ref f g) instance GHC.Show.Show (Data.FixFile.Ptr f) instance GHC.Read.Read (Data.FixFile.Ptr f) instance GHC.Classes.Ord (Data.FixFile.Ptr f) instance GHC.Classes.Eq (Data.FixFile.Ptr f) instance GHC.Generics.Generic (Data.FixFile.Ptr f) instance Data.FixFile.Fixed.Fixed (Data.FixFile.Stored s) instance Data.Binary.Class.Binary (Data.FixFile.Ptr f) instance Data.Hashable.Class.Hashable (Data.FixFile.Ptr f) instance (Data.Typeable.Internal.Typeable f, Data.Binary.Class.Binary (f (Data.FixFile.Ptr f)), Data.Traversable.Traversable f) => Data.FixFile.Root (Data.FixFile.Ref f) instance Data.Binary.Class.Binary (Data.FixFile.Ref f Data.FixFile.Ptr) instance GHC.Base.Functor (Data.FixFile.Transaction f s) instance GHC.Base.Applicative (Data.FixFile.Transaction f s) instance GHC.Base.Monad (Data.FixFile.Transaction f s) instance Control.Monad.State.Class.MonadState (r (Data.FixFile.Stored s)) (Data.FixFile.Transaction r s) -- | This is a BTree data type that can be used with FixFile. It can -- be used as a key-value store where the same key can correspond to -- multiple values. It supports logarithmic insert, lookup, and delete -- operations. module Data.FixFile.BTree -- | A Fixed (BTree k v) stores a BTree of key/value -- pairs. data BTree k v a -- | Create a FixFile storing a (BTree k v). The -- initial value is empty. createBTreeFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree k v))) -- | Open a FixFile storing a (BTree k v). openBTreeFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree k v))) -- | An empty BTree empty :: Fixed g => g (BTree k v) -- | Insert the value v with the key k into a -- Fixed (BTree k v). insertBTree :: (Ord k, Fixed g) => k -> v -> g (BTree k v) -> g (BTree k v) -- | Transaction version of insertBTree. insertBTreeT :: (Ord k, Binary k, Binary v) => k -> v -> Transaction (Ref (BTree k v)) s () -- | Lookup the values stored for the key k in a Fixed -- (BTree k v). lookupBTree :: (Ord k, Fixed g) => k -> g (BTree k v) -> [v] -- | Transaction version of lookupBTree. lookupBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree k v)) s [v] -- | Filter items from a Fixed (BTree k v) for a key -- k that match the predicate. filterBTree :: (Ord k, Fixed g) => k -> (v -> Bool) -> g (BTree k v) -> g (BTree k v) -- | Transaction version of filterBTree. filterBTreeT :: (Ord k, Binary k, Binary v) => k -> (v -> Bool) -> Transaction (Ref (BTree k v)) s () -- | Delete all items for key k from the Fixed -- (BTree k v). deleteBTree :: (Ord k, Fixed g) => k -> g (BTree k v) -> g (BTree k v) -- | Transaction version of deleteBTree. deleteBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree k v)) s () -- | Turn a Fixed (BTree k v) into a list of key -- value tuples. toListBTree :: (Ord k, Fixed g) => g (BTree k v) -> [(k, v)] -- | Turn a list of key value tuples into a Fixed (BTree -- k v). fromListBTree :: (Ord k, Fixed g) => [(k, v)] -> g (BTree k v) instance GHC.Generics.Constructor Data.FixFile.BTree.C1_2BTree instance GHC.Generics.Constructor Data.FixFile.BTree.C1_1BTree instance GHC.Generics.Constructor Data.FixFile.BTree.C1_0BTree instance GHC.Generics.Datatype Data.FixFile.BTree.D1BTree instance Data.Traversable.Traversable (Data.FixFile.BTree.BTree k v) instance Data.Foldable.Foldable (Data.FixFile.BTree.BTree k v) instance GHC.Base.Functor (Data.FixFile.BTree.BTree k v) instance GHC.Generics.Generic (Data.FixFile.BTree.BTree k v a) instance (GHC.Show.Show k, GHC.Show.Show v, GHC.Show.Show a) => GHC.Show.Show (Data.FixFile.BTree.BTree k v a) instance (GHC.Read.Read k, GHC.Read.Read v, GHC.Read.Read a) => GHC.Read.Read (Data.FixFile.BTree.BTree k v a) instance (Data.Binary.Class.Binary k, Data.Binary.Class.Binary v, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Data.FixFile.BTree.BTree k v a) -- | This is a data type that can be used with a FixFile to store a -- set of Ordered items as an unbalanced binary tree. This file -- is not recommended for use, but exists for educational purposes. It -- has a simple implementation that is easier to read than some of the -- more advanced balanced data types. module Data.FixFile.Set -- | A Fixed (Set i) is a set of items represented -- as a binary tree. data Set i a -- | Create a FixFile (Set i). createSetFile :: (Binary i, Typeable i) => FilePath -> IO (FixFile (Ref (Set i))) -- | Open a FixFile (Set i). openSetFile :: (Binary i, Typeable i) => FilePath -> IO (FixFile (Ref (Set i))) -- | An empty Set. empty :: Fixed g => g (Set i) -- | Insert an item i into a Fixed recursive Set -- i. insertSet :: (Ord i, Fixed g) => i -> g (Set i) -> g (Set i) -- | Transaction version of insertSet. insertSetT :: (Ord i, Binary i) => i -> Transaction (Ref (Set i)) s () -- | Delete an item i into a Fixed recursive Set -- i. deleteSet :: (Ord i, Fixed g) => i -> g (Set i) -> g (Set i) -- | Transaction version of deleteSet. deleteSetT :: (Ord i, Binary i) => i -> Transaction (Ref (Set i)) s () -- | Predicate to lookup an item from a Set i. lookupSet :: (Ord i, Fixed g) => i -> g (Set i) -> Bool -- | FTransaction version of lookupSet. lookupSetT :: (Ord i, Binary i) => i -> Transaction (Ref (Set i)) s Bool -- | Turn a Fixed recurive structure of Set i into a -- list. toListSet :: Fixed g => g (Set i) -> [i] -- | Transaction version of toListSet. toListSetT :: Binary i => Transaction (Ref (Set i)) s [i] instance GHC.Generics.Constructor Data.FixFile.Set.C1_1Set instance GHC.Generics.Constructor Data.FixFile.Set.C1_0Set instance GHC.Generics.Datatype Data.FixFile.Set.D1Set instance Data.Traversable.Traversable (Data.FixFile.Set.Set i) instance Data.Foldable.Foldable (Data.FixFile.Set.Set i) instance GHC.Base.Functor (Data.FixFile.Set.Set i) instance GHC.Generics.Generic (Data.FixFile.Set.Set i a) instance (GHC.Show.Show i, GHC.Show.Show a) => GHC.Show.Show (Data.FixFile.Set.Set i a) instance (GHC.Read.Read i, GHC.Read.Read a) => GHC.Read.Read (Data.FixFile.Set.Set i a) instance (Data.Binary.Class.Binary i, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Data.FixFile.Set.Set i a) -- | This is an implementation of a Two-Three Tree data structure that can -- be used with FixFile. It has two interfaces that are module Data.FixFile.Tree23 -- | Type synonym for the Fixed representation of a Two-Three Tree. type Tree23 g d = g (TreeD d) -- | Fixed (TreeD d) represents a Two-Three tree. -- The data type d should have data families for it's key and -- value. These data families are not exported from the module. As a -- result, the only valid types for d are (Set -- k) as defined here or (Map k v), also defined -- here. type TreeD d = Tree23F (TreeKey d) (TreeValue d) -- | An empty Fixed Tree23. empty :: Fixed g => Tree23 g d -- | Predicate that returns true if there are no items in the -- Tree23. null :: Fixed g => Tree23 g d -> Bool -- | Number of entries in (Tree23 g d). size :: Fixed g => Tree23 g d -> Int -- | A Set of k represented as a Two-Three Tree. data Set k -- | Create a FixFile for storing a set of items. createSetFile :: (Binary k, Typeable k) => FilePath -> IO (FixFile (Ref (TreeD (Set k)))) -- | Open a FixFile for storing a set of items. openSetFile :: (Binary k, Typeable k) => FilePath -> IO (FixFile (Ref (TreeD (Set k)))) -- | Insert an item into a set. insertSet :: (Fixed g, Ord k) => k -> Tree23 g (Set k) -> Tree23 g (Set k) -- | Lookup an item in a set. lookupSet :: (Fixed g, Ord k) => k -> Tree23 g (Set k) -> Bool -- | Delete an item from a set. deleteSet :: (Fixed g, Ord k) => k -> Tree23 g (Set k) -> Tree23 g (Set k) -- | Convert a set into a list of items. toListSet :: (Fixed g, Ord k) => Tree23 g (Set k) -> [k] -- | Convert a list of items into a set. fromListSet :: (Fixed g, Ord k) => [k] -> Tree23 g (Set k) -- | Transaction version of insertSet. insertSetT :: (Binary k, Ord k) => k -> Transaction (Ref (TreeD (Set k))) s () -- | FTransaction version of lookupSet. lookupSetT :: (Binary k, Ord k) => k -> Transaction (Ref (TreeD (Set k))) s Bool -- | FTransaction version of deleteSet. deleteSetT :: (Binary k, Ord k) => k -> Transaction (Ref (TreeD (Set k))) s () -- | A Map of keys k to values v represented as a -- Two-Three Tree. data Map k v -- | Create a FixFile of a Map. createMapFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (TreeD (Map k v)))) -- | Open a FixFile of a Map. openMapFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (TreeD (Map k v)))) -- | Insert value v into a map for key k. Any existing -- value is replaced. insertMap :: (Fixed g, Ord k) => k -> v -> Tree23 g (Map k v) -> Tree23 g (Map k v) -- | Lookup an item in a map corresponding to key k. lookupMap :: (Fixed g, Ord k) => k -> Tree23 g (Map k v) -> Maybe v -- | Delete an item from a map at key k. deleteMap :: (Fixed g, Ord k) => k -> Tree23 g (Map k v) -> Tree23 g (Map k v) -- | Apply a function to alter a Map at key k. The function takes -- (Maybe v) as an argument for any possible exiting -- value and returns Nothing to delete a value or Just -- v to set a new value. alterMap :: (Fixed g, Ord k) => k -> (Maybe v -> Maybe v) -> Tree23 g (Map k v) -> Tree23 g (Map k v) -- | Map a function over a map. Because of the way Tree23 is implemented, -- it is not possible to create a Functor instance to achieve this. mapMap :: (Fixed g, Fixed h, Ord k) => (a -> b) -> Tree23 g (Map k a) -> Tree23 h (Map k b) -- | Convert a map into a list of key-value tuples. toListMap :: (Fixed g, Ord k) => Tree23 g (Map k v) -> [(k, v)] -- | Convert a lst of key-value tuples into a map. fromListMap :: (Fixed g, Ord k) => [(k, v)] -> Tree23 g (Map k v) -- | Transaction version of insertMap. insertMapT :: (Binary k, Binary v, Ord k) => k -> v -> Transaction (Ref (TreeD (Map k v))) s () -- | Transaction version of lookupMap. lookupMapT :: (Binary k, Binary v, Ord k) => k -> Transaction (Ref (TreeD (Map k v))) s (Maybe v) -- | Transaction version of deleteMap. deleteMapT :: (Binary k, Binary v, Ord k) => k -> Transaction (Ref (TreeD (Map k v))) s () -- | FTransaction version of alterMap. alterMapT :: (Binary k, Binary v, Ord k) => k -> (Maybe v -> Maybe v) -> Transaction (Ref (TreeD (Map k v))) s () -- | Return the list of keys in a map. keysMap :: (Fixed g, Ord k) => Tree23 g (Map k v) -> [k] -- | Return a list of values in a map. valuesMap :: (Fixed g, Ord k) => Tree23 g (Map k v) -> [v] instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_0R:TreeKeySet instance GHC.Generics.Datatype Data.FixFile.Tree23.D1R:TreeKeySet instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_0R:TreeValueSet instance GHC.Generics.Datatype Data.FixFile.Tree23.D1R:TreeValueSet instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_0R:TreeKeyMap instance GHC.Generics.Datatype Data.FixFile.Tree23.D1R:TreeKeyMap instance GHC.Generics.Selector Data.FixFile.Tree23.S1_0_0R:TreeValueMap instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_0R:TreeValueMap instance GHC.Generics.Datatype Data.FixFile.Tree23.D1R:TreeValueMap instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_3Tree23F instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_2Tree23F instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_1Tree23F instance GHC.Generics.Constructor Data.FixFile.Tree23.C1_0Tree23F instance GHC.Generics.Datatype Data.FixFile.Tree23.D1Tree23F instance GHC.Generics.Generic (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance GHC.Classes.Ord k => GHC.Classes.Ord (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance GHC.Show.Show k => GHC.Show.Show (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance GHC.Read.Read k => GHC.Read.Read (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance GHC.Generics.Generic (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance GHC.Classes.Ord (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance GHC.Classes.Eq (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance GHC.Show.Show (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance GHC.Read.Read (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance GHC.Generics.Generic (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance GHC.Classes.Ord k => GHC.Classes.Ord (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance GHC.Show.Show k => GHC.Show.Show (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance GHC.Read.Read k => GHC.Read.Read (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance GHC.Generics.Generic (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) instance GHC.Classes.Ord v => GHC.Classes.Ord (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) instance GHC.Show.Show v => GHC.Show.Show (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) instance GHC.Read.Read v => GHC.Read.Read (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) instance Data.Traversable.Traversable (Data.FixFile.Tree23.Tree23F k v) instance Data.Foldable.Foldable (Data.FixFile.Tree23.Tree23F k v) instance GHC.Base.Functor (Data.FixFile.Tree23.Tree23F k v) instance GHC.Generics.Generic (Data.FixFile.Tree23.Tree23F k v a) instance (GHC.Classes.Ord k, GHC.Classes.Ord v, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.FixFile.Tree23.Tree23F k v a) instance (GHC.Classes.Eq k, GHC.Classes.Eq v, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.FixFile.Tree23.Tree23F k v a) instance (GHC.Show.Show k, GHC.Show.Show v, GHC.Show.Show a) => GHC.Show.Show (Data.FixFile.Tree23.Tree23F k v a) instance (GHC.Read.Read k, GHC.Read.Read v, GHC.Read.Read a) => GHC.Read.Read (Data.FixFile.Tree23.Tree23F k v a) instance (Data.Binary.Class.Binary a, Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeKey d), Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeValue d)) => Data.Binary.Class.Binary (Data.FixFile.Tree23.Tree23F (Data.FixFile.Tree23.TreeKey d) (Data.FixFile.Tree23.TreeValue d) a) instance Data.Binary.Class.Binary k => Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Set k)) instance Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Set k)) instance Data.Binary.Class.Binary k => Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeKey (Data.FixFile.Tree23.Map k v)) instance Data.Binary.Class.Binary v => Data.Binary.Class.Binary (Data.FixFile.Tree23.TreeValue (Data.FixFile.Tree23.Map k v)) -- | This is a Trie data type that can be used with FixFile. It can -- be used as a key-value store where the key is a ByteString of -- arbitrary size. module Data.FixFile.Trie -- | Fixed (Trie v) is a trie mapping lazy -- ByteStrings to values of type v. data Trie v a -- | An empty Trie empty :: Fixed g => g (Trie v) -- | freeze takes a Trie that has been mutated and creates a -- copy of it that allows for faster lookups. This happens automatically -- for Tries that are serialized to a FixFile. A -- Trie will be automatically thawed on any node that is modified. freeze :: Fixed g => g (Trie v) -> g (Trie v) -- | Create a FixFile of (Trie v) data. createTrieFile :: (Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (Trie v))) -- | Open a FixFile of (Trie v) data. openTrieFile :: (Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (Trie v))) -- | Lookup a possible value stored in a trie for a given -- ByteString key. lookupTrie :: Fixed g => ByteString -> g (Trie v) -> Maybe v -- | Transaction version of lookupTrie. lookupTrieT :: Binary v => ByteString -> Transaction (Ref (Trie v)) s (Maybe v) -- | Insert a value into a trie for the given ByteString key. insertTrie :: Fixed g => ByteString -> v -> g (Trie v) -> g (Trie v) -- | Transaction version of insertTrie. insertTrieT :: Binary v => ByteString -> v -> Transaction (Ref (Trie v)) s () -- | Delete a value from a trie for a given ByteString key. deleteTrie :: Fixed g => ByteString -> g (Trie v) -> g (Trie v) -- | Transaction version of deleteTrie. deleteTrieT :: Binary v => ByteString -> Transaction (Ref (Trie v)) s () -- | Iterate over a Trie for all of the ByteString and value -- tuples for a given ByteString prefix. iterateTrie :: Fixed g => ByteString -> g (Trie v) -> [(ByteString, v)] -- | Transaction version of iterateTrie. iterateTrieT :: Binary v => ByteString -> Transaction (Ref (Trie v)) s [(ByteString, v)] -- | Map a function over a Fixed Trie. Because of the data -- types used, this can't be implemented as a Functor. trieMap :: (Fixed h, Fixed i) => (v -> v') -> h (Trie v) -> i (Trie v') instance GHC.Generics.Constructor Data.FixFile.Trie.C1_5Trie instance GHC.Generics.Constructor Data.FixFile.Trie.C1_4Trie instance GHC.Generics.Constructor Data.FixFile.Trie.C1_3Trie instance GHC.Generics.Constructor Data.FixFile.Trie.C1_2Trie instance GHC.Generics.Constructor Data.FixFile.Trie.C1_1Trie instance GHC.Generics.Constructor Data.FixFile.Trie.C1_0Trie instance GHC.Generics.Datatype Data.FixFile.Trie.D1Trie instance Data.Traversable.Traversable (Data.FixFile.Trie.Trie v) instance Data.Foldable.Foldable (Data.FixFile.Trie.Trie v) instance GHC.Base.Functor (Data.FixFile.Trie.Trie v) instance GHC.Generics.Generic (Data.FixFile.Trie.Trie v a) instance (GHC.Show.Show v, GHC.Show.Show a) => GHC.Show.Show (Data.FixFile.Trie.Trie v a) instance (GHC.Read.Read v, GHC.Read.Read a) => GHC.Read.Read (Data.FixFile.Trie.Trie v a) instance (Data.Binary.Class.Binary v, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Data.FixFile.Trie.Trie v a)