Skip to content

kwasielewski/OneShotEffects.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneShotEffects.jl

OneShotEffects provides implementation of one shot algebraic effects via coroutines in Julia.

To install the library run the following command in Julia REPL:

] add https://github.com/kwasielewski/OneShotEffects.jl

To create an effect handler first register an effect and then provide cases for the handler.

julia> using OneShotEffects

julia> @registerEffect Get

julia> myHandler = handler(Dict(
    Value => (v -> v),
    Get => k -> k(42)
))
(::OneShotEffects.var"#tmp#7"{Dict{DataType, Function}}) (generic function with 2 methods)

To run effectful computation wrap all occurences of effect calls in perform() function and pass thunk to the handler.

julia> retval = myHandler() do
                    x = 2 * perform(Get())
                    println(x)
                end)
# prints 84

About

One shot algebraic effects in Julia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages