Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Effects

Different kinds of effects

  • Single-shot vs. multi-shot vs. zero-shot

    N-shot effects tell the number of times the caller is resumed.

    Zero-shot can be effects like failures/panics. The case where the caller resources should be handled (e.g. drop)

  • Static vs. continuations

  • Tail-resumptive vs. non-/.

Single-shot static tail-resumptive effect is just dependency injection as a language feature.

Reading

Samples

Name resolution

effect Resolve {
  fn resolve(name: Sym) &ref Ty;
}

fn main() {
	let items = <..>;
	let map = Map<Sym, Ty>;

	// I don't like the try/catch-like syntax for effects
	handle {
		items.for |item| {
			'resolve(item);
		}
	} with {
		// no type in effect handling
		fn resolve(name) {
			map.entry(name).match {
				// not long arrows
				.Occupied |ty| effect_continue &ty
				.Vaccant || {
					// it's not in the handle ctx anymore???
					let ty = resolve_item(name);
					map.insert(name, ty);
					effect_continue &ty;
				}
			}
		}
	}
}

fn resolve_item(item: hir::Item) Ty \ Resolve {
	// translate hir to ty
	// ...
	let ty = 'resolve(item.subtype);
	// ...
	ty
}