drasil-database-0.1.1.0: A framework for code and document generation for scientific software - Database SubPackage
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.Drasil.ChunkDB

Synopsis

Core database types and functions.

data ChunkDB Source #

Drasil's knowledge database.

fromList :: IsChunk a => [a] -> ChunkDB Source #

Create a ChunkDB from a list of chunks. This will insert all chunks into the database from the list, from left to right.

registered :: ChunkDB -> [UID] Source #

Query the ChunkDB for all registered chunks (by their UIDs).

typesRegistered :: ChunkDB -> [TypeRep] Source #

Enumerate all types registered in the ChunkDB.

size :: ChunkDB -> Int Source #

Get the number of chunks registered in the ChunkDB.

isRegistered :: UID -> ChunkDB -> Bool Source #

Check if a UID is registered in the ChunkDB.

findUnused :: ChunkDB -> [UID] Source #

Filter the ChunkDB for chunks that are not needed by any other chunks. These are the only chunks that can safely be removed from the database, though we do not include this functionality.

find :: Typeable a => UID -> ChunkDB -> Maybe a Source #

Find a chunk by its UID in the ChunkDB.

findOrErr :: forall a. Typeable a => UID -> ChunkDB -> a Source #

Find a chunk by its UID in the ChunkDB, throwing a hard error if it is not found.

findAll :: forall a. IsChunk a => ChunkDB -> [a] Source #

Find all chunks of a specific type in the ChunkDB.

findAll' :: TypeRep -> ChunkDB -> [UID] Source #

Find all chunks of a specific type in the ChunkDB, returning their UIDs rather than the chunks themselves.

dependants :: UID -> ChunkDB -> Maybe [UID] Source #

Find all chunks that depend on a specific one.

dependantsOrErr :: UID -> ChunkDB -> [UID] Source #

Find all chunks that depend on a specific one, throwing a hard error if the dependency chunk is not found.

findTypeOf :: UID -> ChunkDB -> Maybe TypeRep Source #

Find the type of a chunk by its UID.

insert :: IsChunk a => a -> ChunkDB -> ChunkDB Source #

Insert a chunk into the ChunkDB if it is sensibly to do so (i.e., does not depend on itself and is not a ChunkDB). We temporarily allow chunks to overwrite other ones, but we warn when this happens.

insertAll :: IsChunk a => [a] -> ChunkDB -> ChunkDB Source #

Insert a list of chunks into a ChunkDB.

Temporary functions for working with non-chunk tables

type UMap a = Map UID (a, Int) Source #

An ordered map based on Strict for looking up chunks by their UIDs.

idMap :: HasUID a => [a] -> UMap a Source #

Create a UMap from a list of chunks. Assumes that the leftmost chunk in the list has index 0, increasing by 1 each step to the right.

refFind :: UID -> ChunkDB -> Reference Source #

Find a Reference by its UID, throwing an error if it is not found.

labelledcontentFind :: UID -> ChunkDB -> LabelledContent Source #

Find a LabelledContent by its UID, throwing an error if it is not found.

refbyLookup :: UID -> Map UID [UID] -> [UID] Source #

Find what chunks reference a given UID.

traceLookup :: UID -> Map UID [UID] -> [UID] Source #

Query a chunk for to what chunks it refers to.