## tuplebase.api
#
# API for fully-persistent tuplebase supporting only duples and triples.
# Compiled by:
#
src/lib/std/standard.lib# Compare to:
#
src/lib/src/tuplebasex.api#
src/lib/graph/oop-digraph.api# This api is implemented in:
#
src/lib/src/tuplebase.pkgapi Tuplebase {
#
Other = Exception; # We support the usual hack of using Exception as an extensible datatype to associate arbitrary values with Atoms.
Tuplebase;
Atom;
Duple = (Atom, Atom);
Triple = (Atom, Atom, Atom);
package ds: Set; # Sets of Duples. Set is from
src/lib/src/set.api package ts: Set; # Sets of Triples. Set is from
src/lib/src/set.api make_atom: Void -> Atom; # Create an Atom.
make_string_atom: String -> Atom; # Create an Atom with an associated String value, retrievable via string_of.
make_float_atom: Float -> Atom; # Create an Atom with an associated Float value, retrievable via float_of.
make_tuplebase_atom: Tuplebase -> Atom; # Create an Atom with an associated Other value, retrievable via tuplebase_of.
make_other_atom: Other -> Atom; # Create an Atom with an associated Other value, retrievable via other_of. This allows arbitrary values to be associated with the Atom.
string_of: Atom -> Null_Or(String); # Return String associated with given Atom, if any, else NULL.
float_of: Atom -> Null_Or(Float); # Return Float associated with given Atom, if any, else NULL.
tuplebase_of: Atom -> Null_Or(Tuplebase); # Return Tuplebase associated with given Atom, if any, else NULL.
other_of: Atom -> Null_Or(Other); # Return Other associated with given Atom, if any, else NULL.
empty_tuplebase: Tuplebase;
put_duple: (Tuplebase, Duple ) -> Tuplebase; # Store a Duple into the Tuplebase, returning the updated Tuplebase. The input Tuplebase is unchanged.
put_triple: (Tuplebase, Triple) -> Tuplebase; # Store a Triple into the Tuplebase, returning the updated Tuplebase. The input Tuplebase is unchanged.
drop_duple: (Tuplebase, Duple ) -> Tuplebase; # Remove a Duple from the Tuplebase, returning the updated Tuplebase. The input Tuplebase is unchanged.
drop_triple: (Tuplebase, Triple) -> Tuplebase; # Remove a Triple from the Tuplebase, returning the updated Tuplebase. The input Tuplebase is unchanged.
get_duples: Tuplebase -> ds::Set ; # Get all Duples in Tuplebase. User can iterate via ds::apply etc or do set operations via ds::union etc -- see
src/lib/src/set.api #
get_duples1: (Tuplebase, Atom) -> Null_Or(ds::Set); # Get all Duples in Tuplebase with given Atom in first slot.
get_duples2: (Tuplebase, Atom) -> Null_Or(ds::Set); # Get all Duples in Tuplebase with given Atom in second slot.
#
has_duple: (Tuplebase, Duple) -> Bool; # See if given Duple is in Tuplebase.
get_triples: Tuplebase -> ts::Set ; # Get all Triples in Tuplebase. User can iterate via ts::apply etc or do set operations via ts::union etc -- see src/lib/src/set.api.
#
get_triples1: (Tuplebase, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atom in first slot.
get_triples2: (Tuplebase, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atom in second slot.
get_triples3: (Tuplebase, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atom in third slot.
#
get_triples12: (Tuplebase, Atom, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atoms in first and second slots.
get_triples13: (Tuplebase, Atom, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atoms in first and third slots.
get_triples23: (Tuplebase, Atom, Atom) -> Null_Or(ts::Set); # Get all Triples in Tuplebase with given Atoms in second and third slots.
#
has_triple: (Tuplebase, Triple) -> Bool; # See if given Triple is in Tuplebase.
atoms_apply: Tuplebase -> (Atom -> Void) -> Void; # Apply given fn once per Atom for all Atoms in Tuplebase. This iterates over all tuples in the Tuplebase.
}; # api Tuplebase
## Original code by Jeff Prothero Copyright (c) 2014-2015,
## released per terms of SMLNJ-COPYRIGHT.