necoherence/core

Types

pub type Basis {
  Basis(resource: ResourceId, revision: Revision)
}

Constructors

pub type Command(intent) {
  Command(intent: intent, basis: Basis)
}

Constructors

  • Command(intent: intent, basis: Basis)
pub type Lookup {
  Found(Revision)
  Unknown(UnknownResource)
}

Constructors

pub type Observation(payload) {
  Observation(payload: payload, basis: Basis, observed_at: Int)
}

Constructors

  • Observation(payload: payload, basis: Basis, observed_at: Int)

Closed four-branch outcome: applied, rejected, conflicted, or a boundary failure translated from an external touchpoint.

pub type Outcome(applied, rejected, conflicted, boundary) {
  Applied(applied)
  Rejected(rejected)
  Conflicted(conflicted)
  BoundaryFailed(boundary)
}

Constructors

  • Applied(applied)
  • Rejected(rejected)
  • Conflicted(conflicted)
  • BoundaryFailed(boundary)
pub type ResourceId {
  ResourceId(kind: String, name: String)
}

Constructors

  • ResourceId(kind: String, name: String)
pub type Revision {
  Revision(value: Int)
}

Constructors

  • Revision(value: Int)
pub type StaleBasis {
  StaleBasis(expected: Revision, actual: Revision)
}

Constructors

pub type UnknownResource {
  UnknownResource(resource: ResourceId)
}

Constructors

pub type World {
  World(entries: List(#(ResourceId, Revision)))
}

Constructors

Values

pub fn apply(
  world: World,
  command: Command(intent),
) -> Outcome(
  #(intent, World),
  UnknownResource,
  StaleBasis,
  boundary,
)

Apply a command against world. boundary never occurs here: the four-branch outcome type is shared with the other feature families (Store.apply, file effect) that do produce boundary failures.

pub fn bump(world: World, resource: ResourceId) -> World
pub fn command_of(
  observation: Observation(payload),
  intent: intent,
) -> Command(intent)
pub fn lookup(world: World, resource: ResourceId) -> Lookup
pub fn resource(kind: String, name: String) -> ResourceId
pub fn revision(value: Int) -> Revision
pub fn revision_value(value: Revision) -> Int
pub fn world(entries: List(#(ResourceId, Revision))) -> World
pub fn world_entries(
  value: World,
) -> List(#(ResourceId, Revision))
✨ Search Document