creatur-5.9.30: Framework for artificial life experiments.
Copyright(c) 2012-2021 Amy de Buitléir
LicenseBSD-style
Maintaineramy@nualeargais.ie
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

ALife.Creatur.Database

Description

Database interface for the Créatúr framework.

Synopsis

Documentation

class Database d where Source #

A database offering storage and retrieval for records.

Minimal complete definition

keys, numRecords, archivedKeys, lookup, lookupInArchive, store, delete

Associated Types

type DBRecord d Source #

Methods

keys :: StateT d IO [String] Source #

Get a list of all active keys in the database.

numRecords :: StateT d IO Int Source #

Return the number of records stored in the database.

archivedKeys :: StateT d IO [String] Source #

Get a list of all archived keys in the database. If the database does not implement archiving, it may return an empty list.

lookup :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d)) Source #

Read an active record from the database.

lookupInArchive :: Serialize (DBRecord d) => String -> StateT d IO (Either String (DBRecord d)) Source #

Read an archived record from the database.

readAll :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)] Source #

Fetch all active records from the database.

readAllInArchive :: Serialize (DBRecord d) => StateT d IO [Either String (DBRecord d)] Source #

Read all archived records from the database.

store :: (Record (DBRecord d), Serialize (DBRecord d)) => DBRecord d -> StateT d IO () Source #

Write a record to the database. If an agent with the same name already exists, it will be overwritten.

delete :: Serialize (DBRecord d) => String -> StateT d IO () Source #

Remove a record from the database. The database may archive records rather than simply deleting them.

Instances

Instances details
Database (FSDatabase r) Source # 
Instance details

Defined in ALife.Creatur.Database.FileSystem

Associated Types

type DBRecord (FSDatabase r) Source #

SizedRecord r => Database (CachedFSDatabase r) Source # 
Instance details

Defined in ALife.Creatur.Database.CachedFileSystemInternal

Associated Types

type DBRecord (CachedFSDatabase r) Source #

class Record r where Source #

Methods

key :: r -> String Source #

class Record r => SizedRecord r where Source #

Methods

size :: r -> Int Source #