Skuld.Comp.Types (skuld v0.3.0)

View Source

Type definitions for Skuld.Comp.

These types define the core abstractions of the evidence-passing effect system.

Summary

Types

A computation awaiting execution.

The environment carrying evidence, state, and leave-scope

A handler interprets effect operations

k()

Continuation after an effect

Leave-scope handler - cleans up or redirects

Any result value - opaque to the framework

Effect signature - identifies which handler handles an operation. Can be a simple atom or a tuple for tagged effects.

Transform-suspend handler - decorates ExternalSuspend values when yielding

Types

computation()

@type computation() :: computation(term())

computation(_result)

@type computation(_result) :: (env(), k() -> {result(), env()})

A computation awaiting execution.

The type parameter documents what the computation produces when run. Dialyzer erases it (it's a phantom parameter), but it appears in hover docs, ExDoc, and generated specs for readability.

Examples

@spec get_todo(String.t()) :: computation({:ok, Todo.t()} | {:error, term()})
@spec get_todo!(String.t()) :: computation(Todo.t())

env()

@type env() :: Skuld.Comp.Env.t()

The environment carrying evidence, state, and leave-scope

handler()

@type handler() :: (args :: term(), env(), k() -> {result(), env()})

A handler interprets effect operations

k()

@type k() :: (term(), env() -> {result(), env()})

Continuation after an effect

leave_scope()

@type leave_scope() :: (result(), env() -> {result(), env()})

Leave-scope handler - cleans up or redirects

result()

@type result() :: term()

Any result value - opaque to the framework

sig()

@type sig() :: atom() | {atom(), atom()}

Effect signature - identifies which handler handles an operation. Can be a simple atom or a tuple for tagged effects.

transform_suspend()

@type transform_suspend() :: (Skuld.Comp.ExternalSuspend.t(), env() ->
                          {Skuld.Comp.ExternalSuspend.t(), env()})

Transform-suspend handler - decorates ExternalSuspend values when yielding