aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/SubstantialRelation.mli
blob: 866c3a097915a8cdd20da6b7fbf67116d5a74ce9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Make (S : Abstract.Storage.STORAGE) (Schematics : sig
  include Protocols.Schematics.S
  val of_blob : Concepts.Blob.t -> (Schema.t, Concepts.Condition.condition) result
end) : sig
  type t

  val encode : t -> Concepts.Blob.t
  val decode : Concepts.Blob.t -> (t, Concepts.Condition.condition) result

  val empty :
    S.transaction ->
    heading:Concepts.Hash.hash ->
    ?predicate:Concepts.Hash.hash ->
    ?local_constraints:Concepts.Hash.hash ->
    ?indexes:Concepts.Hash.hash ->
    unit ->
    (t, Concepts.Condition.condition) result

  val store : S.transaction -> t -> (Concepts.Hash.hash, Concepts.Condition.condition) result

  val make :
    S.connection ->
    heading:Concepts.Hash.hash ->
    ?predicate:Concepts.Hash.hash ->
    ?local_constraints:Concepts.Hash.hash ->
    ?indexes:Concepts.Hash.hash ->
    unit ->
    (Protocols.Handle.t, Concepts.Condition.condition) result

  val load_value : S.transaction -> Concepts.Hash.hash -> (t, Concepts.Condition.condition) result

  val wrap : S.connection -> t -> (Protocols.Handle.t, Concepts.Condition.condition) result

  val load :
    S.transaction ->
    S.connection ->
    Concepts.Hash.hash ->
    (Protocols.Handle.t, Concepts.Condition.condition) result

  val heading : t -> Concepts.Hash.hash
  val predicate : t -> Concepts.Hash.hash option
  val local_constraints : t -> Concepts.Hash.hash option
  val tuples : t -> Concepts.Hash.hash
  val indexes : t -> Concepts.Hash.hash option
  val hash : t -> Concepts.Hash.hash

  val assert_tuple :
    S.transaction -> t -> Concepts.Blob.t -> (t, Concepts.Condition.condition) result

  val contains_tuple :
    S.transaction -> t -> Concepts.Blob.t -> (bool, Concepts.Condition.condition) result

  (** decodes the heading at [heading relation] -- the body of
      [Schematics.schema] for this kind of relation. *)
  val heading_value : S.transaction -> t -> (Schematics.Schema.t, Concepts.Condition.condition) result

  (** a handle carrying [Protocols.Cursor] over every tuple currently
      asserted, decoded via [Concepts.Tuple.Representation.of_blob] --
      the body of [Protocols.Relation.enumerate] for this kind of
      relation. Opens its own storage transaction, held for the
      cursor's whole lifetime rather than just this call -- see
      [Kernel.Generator] and docs/design/evaluator.md, "Shape". *)
  val enumerate : S.connection -> t -> (Protocols.Handle.t, Concepts.Condition.condition) result
end