| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Drasil.Database
Description
Re-export database types and functions to simplify external use.
Synopsis
- data Chunk
- type IsChunk a = (HasUID a, HasChunkRefs a, Typeable a)
- class HasChunkRefs a where
- mkChunk :: IsChunk a => a -> Chunk
- unChunk :: Typeable a => Chunk -> Maybe a
- chunkType :: Chunk -> TypeRep
- data ChunkDB
- empty :: ChunkDB
- fromList :: IsChunk a => [a] -> ChunkDB
- registered :: ChunkDB -> [UID]
- typesRegistered :: ChunkDB -> [TypeRep]
- size :: ChunkDB -> Int
- isRegistered :: UID -> ChunkDB -> Bool
- findUnused :: ChunkDB -> [UID]
- find :: Typeable a => UID -> ChunkDB -> Maybe a
- findOrErr :: forall a. Typeable a => UID -> ChunkDB -> a
- findAll :: forall a. IsChunk a => ChunkDB -> [a]
- findAll' :: TypeRep -> ChunkDB -> [UID]
- dependants :: UID -> ChunkDB -> Maybe [UID]
- dependantsOrErr :: UID -> ChunkDB -> [UID]
- findTypeOf :: UID -> ChunkDB -> Maybe TypeRep
- insert :: IsChunk a => a -> ChunkDB -> ChunkDB
- insertAll :: IsChunk a => [a] -> ChunkDB -> ChunkDB
- insertAllOutOfOrder11 :: (IsChunk a, IsChunk b, IsChunk c, IsChunk d, IsChunk e, IsChunk f, IsChunk g, IsChunk h, IsChunk i, IsChunk j, IsChunk k) => ChunkDB -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h] -> [i] -> [j] -> [k] -> ChunkDB
- type ChunkType = String
- type DumpedChunkDB = Map ChunkType [UID]
- dumpChunkDB :: ChunkDB -> DumpedChunkDB
- data UID
- class HasUID c where
- mkUid :: String -> UID
- nsUid :: String -> UID -> UID
- (+++) :: HasUID a => a -> String -> UID
- (+++.) :: UID -> String -> UID
- (+++!) :: (HasUID a, HasUID b) => a -> b -> UID
- showUID :: HasUID a => a -> String
- data TypedUIDRef typ
- mkRef :: IsChunk t => t -> TypedUIDRef t
- typedFind :: IsChunk t => TypedUIDRef t -> ChunkDB -> Maybe t
- typedFindOrErr :: IsChunk t => TypedUIDRef t -> ChunkDB -> t
Documentation
A piece of reusable knowledge, with an internal identifier (UID),
possibly dependant on other chunks.
type IsChunk a = (HasUID a, HasChunkRefs a, Typeable a) Source #
Constraint for anything that may be considered a valid chunk type.
class HasChunkRefs a where Source #
All chunks should expose what chunks they reference/rely on, so that we can
test ChunkDBs to ensure all presupposed chunks are already registered.
Core database types and functions.
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.
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.
findAll :: forall a. IsChunk a => ChunkDB -> [a] Source #
Find all chunks of a specific type in the ChunkDB.
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.
Temporary functions
insertAllOutOfOrder11 :: (IsChunk a, IsChunk b, IsChunk c, IsChunk d, IsChunk e, IsChunk f, IsChunk g, IsChunk h, IsChunk i, IsChunk j, IsChunk k) => ChunkDB -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h] -> [i] -> [j] -> [k] -> ChunkDB Source #
dumpChunkDB :: ChunkDB -> DumpedChunkDB Source #
A UID is a 'unique identifier' for things that we will put into our
database of information. We use a newtype wrapper to make sure we are only
using UIDs where desired.
Instances
| ToJSON UID Source # | |
Defined in Drasil.Database.UID | |
| ToJSONKey UID Source # | |
Defined in Drasil.Database.UID | |
| Generic UID Source # | |
| Show UID Source # | |
| Eq UID Source # | |
| Ord UID Source # | |
| type Rep UID Source # | |
Defined in Drasil.Database.UID type Rep UID = D1 ('MetaData "UID" "Drasil.Database.UID" "drasil-database-0.1.1.0-5oPj4CLw7PwuDH58oM3Qz" 'False) (C1 ('MetaCons "UID" 'PrefixI 'True) (S1 ('MetaSel ('Just "_namespace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [String]) :*: S1 ('MetaSel ('Just "_baseName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))) | |
The most basic item: having a unique identifier key, here a UID.
(+++!) :: (HasUID a, HasUID b) => a -> b -> UID Source #
Merge the UIDs of two chunks through simple concatenation.
data TypedUIDRef typ Source #
mkRef :: IsChunk t => t -> TypedUIDRef t Source #
Create a TypedUIDRef to a chunk.
typedFind :: IsChunk t => TypedUIDRef t -> ChunkDB -> Maybe t Source #
Find a chunk by its typed UID reference.
typedFindOrErr :: IsChunk t => TypedUIDRef t -> ChunkDB -> t Source #
Find a chunk by its typed UID reference, erroring if not found.