-- 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.4.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 Typeable, -- 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 -- | FixedAlg is a typeclass for describing the relationship between -- a Functor that is used with a Fixed combinator and an -- algebraic datatype in that Functor other than the one used for -- fixed-point recursion. class FixedAlg (f :: * -> *) where type Alg f :: * where { type family Alg f :: *; } -- | FixedSub is a typeclass for describing the relationship between -- a FixedAlg Functor f and that same -- Functor with Alg f switched from v to -- v'. class FixedAlg f => FixedSub f where type Sub f v v' :: * -> * where { type family Sub f v v' :: * -> *; } -- | FixedFunctor is a typeclass for describing mapping behavior for -- datatypes used with Fixed combinators. class FixedSub f => FixedFunctor f -- | Map over a Fixed recursive FixedSub f. fmapF :: (FixedFunctor f, Fixed g, Fixed g', a ~ Alg f) => (a -> b) -> g f -> g' (Sub f a b) -- | fmapF, but using a single instance of Fixed. fmapF' :: (FixedFunctor f, Fixed g, a ~ Alg f) => (a -> b) -> g f -> g (Sub f a b) -- | FixedFoldable is a typeclass for describing folds over -- datatypes with Fixed combinators. class FixedAlg f => FixedFoldable f -- | Fold over a Fixed recursive FixedAlg f. foldMapF :: (FixedFoldable f, Fixed g, Monoid m, a ~ Alg f) => (a -> m) -> g f -> m -- | FixedTraversable is a typeclass for describing traversals over -- datatypes with Fixed combinators. class FixedSub f => FixedTraversable f -- | Traverse over a Fixed recursive FixedSub f in -- the Applicative h. traverseF :: (FixedTraversable f, Fixed g, Fixed g', Applicative h, a ~ Alg f) => (a -> h b) -> g f -> h (g' (Sub f a b)) -- | traverseF, but using a single instance of Fixed. traverseF' :: (FixedTraversable f, Fixed g, Applicative h, a ~ Alg f) => (a -> h b) -> g f -> h (g (Sub f a b)) -- | A Constraint for data that can be used with a Ref type Fixable f = (Traversable f, Binary (f (Ptr f)), Typeable f) -- | FixTraverse is a class based on Traverse but taking an -- argument of kind ((* -> *) -> *) instead of *. class FixTraverse (t :: ((* -> *) -> *) -> *) -- | Given a function that maps from a to b over -- Fixable g in the Applicative f, -- traverse over t changing the fixed-point combinator from -- a to b. sequenceAFix :: (FixTraverse t, Applicative f) => (forall g. Fixable g => a g -> f (b g)) -> t a -> f (t b) -- | A Root is a datastructure that is an instance of -- FixTraverse and Binary. This acts as a sort of "header" -- for the file where the Root may have several Refs under -- it to different Functors. type Root r = (FixTraverse r, Binary (r Ptr)) -- | 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 => 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 => 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 () -- | Get the FilePath of a FixFile. fixFilePath :: FixFile r -> FilePath -- | It's potentially useful to copy the contents of a FixFile to a -- new location as a backup. The clone function essentially runs -- vacuum on a FixFile, but writes the output to the -- specified path. clone :: Root r => FilePath -> 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 => 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 => FixFile r -> (forall s. Transaction r s a) -> IO a -- | The writeExceptTransaction function behaves like -- writeTransaction, but applies to a Transaction wrapped -- in ExceptT. In the event that an exception propagates through -- the Transaction, the updates are not committed to disk. -- -- This is meant to provide a mechanism for aborting Transactions. writeExceptTransaction :: Root r => FixFile r -> (forall s. ExceptT e (Transaction r s) a) -> IO (Either e 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 root datastructure from the transaction as r -- Fix. getRoot :: Root r => Transaction r s (r Fix) -- | Get the full datastructure from the transaction as a Fix -- f. getFull :: Functor f => Transaction (Ref f) s (Fix f) 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.Binary.Class.Binary (Data.FixFile.Ref f Data.FixFile.Ptr) instance Data.FixFile.Fixable f => Data.FixFile.FixTraverse (Data.FixFile.Ref f) 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 n k v) stores a BTree of -- key/value pairs. n should be a Nat and will be the -- maximum number of elements in each branch of the BTree. data BTree (n :: Nat) k v a -- | Create a FixFile storing a (BTree k v). The -- initial value is empty. createBTreeFile :: (Typeable n, Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree n k v))) -- | Open a FixFile storing a (BTree k v). openBTreeFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree n k v))) -- | An empty BTree empty :: Fixed g => g (BTree n k v) -- | Compute the depth of a BTree depth :: Fixed g => g (BTree n k v) -> Int -- | Insert the value v with the key k into a -- Fixed (BTree k v). insertBTree :: (KnownNat n, Ord k, Fixed g) => k -> v -> g (BTree n k v) -> g (BTree n k v) -- | Transaction version of insertBTree. insertBTreeT :: (KnownNat n, Ord k, Binary k, Binary v) => k -> v -> Transaction (Ref (BTree n 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 n k v) -> [v] -- | Transaction version of lookupBTree. lookupBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree n 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 n k v) -> g (BTree n k v) -- | Transaction version of filterBTree. filterBTreeT :: (Ord k, Binary k, Binary v) => k -> (v -> Bool) -> Transaction (Ref (BTree n k v)) s () -- | Delete all items for key k from the Fixed -- (BTree k v). deleteBTree :: (Ord k, Fixed g) => k -> g (BTree n k v) -> g (BTree n k v) -- | Transaction version of deleteBTree. deleteBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree n k v)) s () -- | Split a BTree into two two BTrees with keys and -- keys k. partitionBTree :: (Ord k, Fixed g) => k -> g (BTree n k v) -> (g (BTree n k v), g (BTree n k v)) -- | Turn a Fixed (BTree k v) into a list of key -- value tuples. toListBTree :: (Ord k, Fixed g) => g (BTree n k v) -> [(k, v)] -- | Turn a list of key value tuples into a Fixed (BTree -- k v). fromListBTree :: (KnownNat n, Ord k, Fixed g) => [(k, v)] -> g (BTree n k v) instance Data.Traversable.Traversable (Data.FixFile.BTree.BTree n k v) instance Data.Foldable.Foldable (Data.FixFile.BTree.BTree n k v) instance GHC.Base.Functor (Data.FixFile.BTree.BTree n k v) instance GHC.Generics.Generic (Data.FixFile.BTree.BTree n k v a) instance (GHC.Show.Show k, GHC.Show.Show v, GHC.Show.Show a) => GHC.Show.Show (Data.FixFile.BTree.BTree n k v a) instance (GHC.Read.Read k, GHC.Read.Read v, GHC.Read.Read a) => GHC.Read.Read (Data.FixFile.BTree.BTree n 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 n k v a) instance Data.FixFile.Fixed.FixedAlg (Data.FixFile.BTree.BTree n k v) instance Data.FixFile.Fixed.FixedSub (Data.FixFile.BTree.BTree n k v) instance Data.FixFile.Fixed.FixedFunctor (Data.FixFile.BTree.BTree n k v) instance Data.FixFile.Fixed.FixedFoldable (Data.FixFile.BTree.BTree n k v) instance Data.FixFile.Fixed.FixedTraversable (Data.FixFile.BTree.BTree n k v) -- | 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. -- | Warning: Set is unbalanced and not recommended. 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 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) instance Data.FixFile.Fixed.FixedAlg (Data.FixFile.Set.Set i) instance Data.FixFile.Fixed.FixedFoldable (Data.FixFile.Set.Set i) -- | 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 -- | Fixed (Tree23 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 Tree23 d = Tree23F (TreeKey d) (TreeValue d) -- | An empty Fixed Tree23. empty :: Fixed g => g (Tree23 d) -- | Predicate that returns true if there are no items in the -- Tree23. null :: Fixed g => g (Tree23 d) -> Bool -- | Number of entries in (Tree23 g d). size :: Fixed g => g (Tree23 d) -> Int -- | The depth of (Tree23 g d). 0 represents en -- empty Tree. depth :: Fixed g => g (Tree23 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, f ~ Tree23 (Set k)) => FilePath -> IO (FixFile (Ref f)) -- | Open a FixFile for storing a set of items. openSetFile :: (Binary k, Typeable k, f ~ Tree23 (Set k)) => FilePath -> IO (FixFile (Ref f)) -- | Insert an item into a set. insertSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => k -> g f -> g f -- | Lookup an item in a set. lookupSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => k -> g f -> Bool -- | Delete an item from a set. deleteSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => k -> g f -> g f -- | Split a set into sets of items and= k partitionSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => k -> g f -> (g f, g f) -- | return the minimum value minSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => g f -> Maybe k -- | return the minimum value maxSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => g f -> Maybe k -- | Convert a set into a list of items. toListSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => g f -> [k] -- | Convert a list of items into a set. fromListSet :: (Fixed g, Ord k, f ~ Tree23 (Set k)) => [k] -> g f -- | Transaction version of insertSet. insertSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => k -> Transaction (Ref f) s () -- | FTransaction version of lookupSet. lookupSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => k -> Transaction (Ref f) s Bool -- | FTransaction version of deleteSet. deleteSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => k -> Transaction (Ref f) s () -- | Transaction version of partitionSet. partitionSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => k -> Transaction (Ref f) s (Stored s f, Stored s f) -- | FTransaction version of minSet. minSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => Transaction (Ref f) s (Maybe k) -- | FTransaction version of minSet. maxSetT :: (Binary k, Ord k, f ~ Tree23 (Set k)) => Transaction (Ref f) s (Maybe k) -- | 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, f ~ Tree23 (Map k v)) => FilePath -> IO (FixFile (Ref f)) -- | Open a FixFile of a Map. openMapFile :: (Binary k, Typeable k, Binary v, Typeable v, f ~ Tree23 (Map k v)) => FilePath -> IO (FixFile (Ref f)) -- | Insert value v into a map for key k. Any existing -- value is replaced. insertMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => k -> v -> g f -> g f -- | Lookup an item in a map corresponding to key k. lookupMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => k -> g f -> Maybe v -- | Delete an item from a map at key k. deleteMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => k -> g f -> g f -- | Split a set into maps for keys and= k partitionMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => k -> g f -> (g f, g f) -- | 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, f ~ Tree23 (Map k v)) => k -> (Maybe v -> Maybe v) -> g f -> g f -- | return the minimum key and value minMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => g f -> Maybe (k, v) -- | return the maximum key and value maxMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => g f -> Maybe (k, v) -- | Convert a map into a list of key-value tuples. toListMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => g f -> [(k, v)] -- | Convert a lst of key-value tuples into a map. fromListMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => [(k, v)] -> g f -- | Transaction version of insertMap. insertMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => k -> v -> Transaction (Ref f) s () -- | Transaction version of lookupMap. lookupMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => k -> Transaction (Ref f) s (Maybe v) -- | Transaction version of deleteMap. deleteMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => k -> Transaction (Ref f) s () -- | Transaction version of partitionMap. partitionMapT :: (Binary k, Ord k, Binary v, f ~ Tree23 (Map k v)) => k -> Transaction (Ref f) s (Stored s f, Stored s f) -- | FTransaction version of alterMap. alterMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => k -> (Maybe v -> Maybe v) -> Transaction (Ref f) s () -- | FTransaction version of minMap. minMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => Transaction (Ref f) s (Maybe (k, v)) -- | FTransaction version of minMap. maxMapT :: (Binary k, Binary v, Ord k, f ~ Tree23 (Map k v)) => Transaction (Ref f) s (Maybe (k, v)) -- | Return the list of keys in a map. keysMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => g f -> [k] -- | Return a list of values in a map. valuesMap :: (Fixed g, Ord k, f ~ Tree23 (Map k v)) => g f -> [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 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.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.FixFile.Fixed.FixedAlg (Data.FixFile.Tree23.Tree23 (Data.FixFile.Tree23.Set k)) instance Data.FixFile.Fixed.FixedFoldable (Data.FixFile.Tree23.Tree23 (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)) instance Data.FixFile.Fixed.FixedAlg (Data.FixFile.Tree23.Tree23 (Data.FixFile.Tree23.Map k v)) instance Data.FixFile.Fixed.FixedSub (Data.FixFile.Tree23.Tree23 (Data.FixFile.Tree23.Map k v)) instance Data.FixFile.Fixed.FixedFunctor (Data.FixFile.Tree23.Tree23 (Data.FixFile.Tree23.Map k v)) instance Data.FixFile.Fixed.FixedFoldable (Data.FixFile.Tree23.Tree23 (Data.FixFile.Tree23.Map k v)) instance Data.FixFile.Fixed.FixedTraversable (Data.FixFile.Tree23.Tree23 (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)] 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) instance Data.FixFile.Fixed.FixedAlg (Data.FixFile.Trie.Trie v) instance Data.FixFile.Fixed.FixedSub (Data.FixFile.Trie.Trie v) instance Data.FixFile.Fixed.FixedFunctor (Data.FixFile.Trie.Trie v) instance Data.FixFile.Fixed.FixedFoldable (Data.FixFile.Trie.Trie v) instance Data.FixFile.Fixed.FixedTraversable (Data.FixFile.Trie.Trie v)