Docs / Semantics / Composition / Effect

Types with effects

import Linglib.Semantics.Composition.Effect · namespace Interpreter

Bumford and Charlow type an expression whose meaning exceeds what its position expects as a computation with an effect: a pronoun reads a referent, a definite description may fail, an appositive stores a comment, a wh-phrase returns one of several values, and a quantifier consults its continuation. A computation type is an effect applied to the type of its result. Each effect is a functor, and each but storing at a type with no way of merging two stored contents is applicative and a monad; storing is left adjoint to reading, and reading distributes over functions.

Main definitions

Implementation notes

Truth values are a type of their own and not a base sort, since predicate modification, lowering and the merging of stored truth values name them. The carriers are the standard ones, Set, functions, products, Cont and Part, and the operations are theirs. Storing is applicative only at the truth values, merged by conjunction, as in the book's interpreter. State and dynamic state are not effects here: the book derives them from storing and reading.

References

Declarations

The types over base sorts B: truth values, a base sort, functions, and computations with an effect.

inductive TyL51–62
(B : Type) :
  • t {B : Type} : Ty B

    Truth values.

  • base {B : Type} (b : B) : Ty B

    A base sort.

  • fn {B : Type} (a b : Ty B) : Ty B

    Functions.

  • comp {B : Type} (f : Eff B) (a : Ty B) : Ty B

    Computations with effect f and result of type a.

Derives DecidableEq, Repr.

Built from

Used by instDecidableEqEff.decEq_1, instReprEff.repr_1, Eff, Ty.Dom, Eff.counit, Eff.eject, Eff.lower, Ty.size

Used in Morphology/DistributedMorphology/Nominalization, Semantics/Composition/CallByValue, Semantics/Composition/Coordination, Semantics/Composition/Extension, Semantics/Composition/Interpret and 42 more

L62

The effects.

inductive EffL64–76
(B : Type) :
  • S {B : Type} : Eff B

    Indeterminacy: a set of alternative results.

  • R {B : Type} (i : Ty B) : Eff B

    Reading a datum of type i.

  • W {B : Type} (o : Ty B) : Eff B

    Storing a datum of type o.

  • C {B : Type} (r : Ty B) : Eff B

    Quantifying over continuations with result type r.

  • M {B : Type} : Eff B

    Partiality: a result that may be undefined.

Built from

Used by Ty, instReprEff, instDecidableEqEff.decEq_2, instReprEff.repr_2, instDecidableEqEff, Eff.F, Eff.IsApplicative, Eff.map, Eff.pure, Eff.seq, Eff.join, Eff.map_id, Eff.map_map, Eff.size

Used in Semantics/Composition/LiftRel, Semantics/Composition/Mode, BumfordCharlow2026

L80

The domain of a type, given the domains of the base sorts.

@[reducible, inline] abbrev Ty.DomL86–92
{B : Type} (D : B → Type) (ty : Ty B) :

Built from ,

Instances Elbourne2026.instStructureTyLiftingDom, Interpreter.effectGrammar.structure, Interpreter.instStructureTyApplicationDom, Interpreter.instStructureTyEventIdentificationDom, Interpreter.instStructureTyPredicateModificationDom and 2 more

Used by Eff.F, Eff.map, Eff.pure, Eff.seq, Eff.join, Eff.lower

Used in Morphology/DistributedMorphology/Nominalization, Semantics/Composition/CallByValue, Semantics/Composition/Coordination, Semantics/Composition/Extension, Semantics/Composition/Interpret and 32 more

The carrier of an effect: a set of alternatives, a function of the datum read, a pair with the datum stored, a function of the continuation, or a partial value.

@[reducible, inline] abbrev Eff.FL94–102
{B : Type} (D : B → Type) (f : Eff B) (α : Type) :

Built from ,

Used by Ty.Dom, Eff.map, Eff.pure, Eff.seq, Eff.join, Eff.counit, Eff.eject, Eff.lower, Eff.map_id, Eff.map_map

Used in Semantics/Composition/LiftRel

L116–118

An effect's map.

def Eff.mapL120–126
{B : Type} {D : B → Type} {α β : Type} (f : Eff B) :
(α → β) → F D f α → F D f β
  • Eff.S.map x✝ x_3 = x✝ '' x_3
  • (Eff.R i).map x✝ x_3 = fun (i : Ty.Dom D i) => x✝ (x_3 i)
  • (Eff.W o).map x✝ x_3 = (x✝ x_3.1, x_3.2)
  • (Eff.C r).map x✝ x_3 = fun (c : β → Id (Ty.Dom D r)) => x_3 fun (a : α) => c (x✝ a)
  • Eff.M.map x✝ x_3 = Part.map x✝ x_3

Built from , ,

Used by Eff.map_id, Eff.map_map

Used in Semantics/Composition/LiftRel, Semantics/Composition/Mode

L162–165
L167–172