Skuld.Adapter.EffectfulContract (skuld v0.30.0)
View SourceGenerates an effectful behaviour from a DoubleDown.Contract.
use Skuld.Adapter.EffectfulContract reads the operations from a
plain DoubleDown contract and generates:
- Effectful
@callbackdeclarations withcomputation(return_type)return types on the using module __callbacks__/0— copied from the DoubleDown contract__port_effectful__?/0— marker for effectful resolver auto-detection
The effectful contract module is the effectful behaviour. Effectful
implementations declare @behaviour MyApp.Todos.Effectful.
Usage
# Plain contract (DoubleDown)
defmodule MyApp.Todos.Contract do
use DoubleDown.Contract
defcallback get_todo(id :: String.t()) :: {:ok, Todo.t()} | {:error, term()}
end
# Effectful contract (Skuld)
defmodule MyApp.Todos.Effectful do
use Skuld.Adapter.EffectfulContract,
double_down_contract: MyApp.Todos.Contract
end
# Effectful facade
defmodule MyApp.Todos do
use Skuld.Effects.Port.EffectfulFacade, contract: MyApp.Todos.Effectful
endEffectful Implementation
defmodule MyApp.Todos.EffectfulImpl do
@behaviour MyApp.Todos.Effectful
def get_todo(id) do
{:ok, %Todo{id: id}}
end
endOptions
:double_down_contract(required) — the DoubleDown contract module that defines__callbacks__/0viause DoubleDown.Contract.