Effect: Difference between revisions
(initial article) |
(No difference)
|
Revision as of 02:16, 28 August 2024
An effect is a concept from programming languages: there, it describes a way in which something that behaves essentially like a function that takes an "A" and returns a "B" might do more than just that pure computation (that is: it may have "side effects").
It turns out that we can apply a similar perspective to natural language semantics by describing certain processes as "effects", and this plays very nicely with existing ideas about compositional syntax.
Examples from programming
Let's consider possible "side effects" of a function A → B. It might...
- throw an error of type Err instead of actually returning a result of type B.
- return some "log" data alongside its result of type B.
- depend on / read some "environment" data in order to produce a result of type B.
One way a programming language can encode this is using monads. Basically, we say we have functions of types like
- A → Either Err B
- A → Writer Log B
- A → Reader Env B
and we rely on some way to compose these functions, while propagating their effects.
- We can compose two throwing functions into a larger throwing function.
- We can compose two logging functions into a larger logging function.
- We can compose two functions that read from the environment into a larger such function.
By composing many functions with different effects, we arrive at one big function that is clear about the essential data types involved in its transformation, while also describing the exact "effectful context" it wants to run in (does it need a "catch Err" block? some sink to collect logs? some source of environment data?)
In syntax
It turns out that we can extend this concept to syntax. For example, consider a noun phrase with an apposition, like Mary, a linguist. This seems to be essentially (syntactically) an entity of type e that also wants to "write" a presupposition like "Mary is a linguist" to some environment. So, we say that it is an entity e in an effectful context W, and we write this as the subtree having type W e.
When we move up the tree to a bigger constituent like I saw Mary, a linguist, we want to keep this effectful context and "lift" the rest of the sentence, I saw (of type e → t), into it. We first turn e → t into W (e → t) and then compose this with our W e to get a W t.
Eventually, we arrive at a denoted sentence wrapped in a list of effects (presuppositions, bindings, focus…) gathered from everywhere in the sentence.
(TODO: more examples from esslli slides, maybe in Toaq)
See also
- Effectful composition in natural language semantics, slides by Dylan Bumford and Simon Charlow.
- https://ncatlab.org/nlab/show/monad+%28in+linguistics%29