memdb-1.0.0.3: Efficient in memory indexed database

Safe HaskellNone
LanguageHaskell2010

Database.Immutable.Write

Contents

Synopsis

Offset and Limit data types

newtype Id a Source #

Offset into the database.

Constructors

Id 

Fields

Instances
Eq (Id a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

(==) :: Id a -> Id a -> Bool #

(/=) :: Id a -> Id a -> Bool #

Ord (Id a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

compare :: Id a -> Id a -> Ordering #

(<) :: Id a -> Id a -> Bool #

(<=) :: Id a -> Id a -> Bool #

(>) :: Id a -> Id a -> Bool #

(>=) :: Id a -> Id a -> Bool #

max :: Id a -> Id a -> Id a #

min :: Id a -> Id a -> Id a #

Show (Id a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

showsPrec :: Int -> Id a -> ShowS #

show :: Id a -> String #

showList :: [Id a] -> ShowS #

Serialize (Id a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

put :: Putter (Id a) #

get :: Get (Id a) #

newtype Limit a Source #

Limit the number of elements read after an Id.

Constructors

Limit 

Fields

Instances
Eq (Limit a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

(==) :: Limit a -> Limit a -> Bool #

(/=) :: Limit a -> Limit a -> Bool #

Ord (Limit a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

compare :: Limit a -> Limit a -> Ordering #

(<) :: Limit a -> Limit a -> Bool #

(<=) :: Limit a -> Limit a -> Bool #

(>) :: Limit a -> Limit a -> Bool #

(>=) :: Limit a -> Limit a -> Bool #

max :: Limit a -> Limit a -> Limit a #

min :: Limit a -> Limit a -> Limit a #

Show (Limit a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

showsPrec :: Int -> Limit a -> ShowS #

show :: Limit a -> String #

showList :: [Limit a] -> ShowS #

Serialize (Limit a) Source # 
Instance details

Defined in Database.Immutable.Internal

Methods

put :: Putter (Limit a) #

get :: Get (Limit a) #

incId :: Id a -> Id a Source #

Increment Id.

subIds :: Id a -> Id a -> Limit a Source #

Subtract two Ids, returning a Limit including both - i.e. slice a (subIds b a) db will include both a and b.

addLimit a (subIds b a) == b

Writing

writeDB Source #

Arguments

:: Serialize a 
=> FilePath

File path, must be writeable

-> ((a -> IO ()) -> IO r)

Writing function; the continuation can be called multiple times

-> IO r 

Write data sequentially to a database file. Database files can be read back using readDB.

An additional file path.meta is produced holding the number of written elements.

fromList :: Serialize a => [a] -> ByteString Source #

Creata a database from a list. Databases can be created back using createDB.