#Swift Effect is now in public preview! It's an architecture-agnostic effect system that makes side effects (such as I/O, networking, and concurrency) controllable and testable while keeping application code linear and procedural (no UDF!). Effect Handlers enable natural composition of behaviors. Mock-less testing with step-by-step execution by catching and resuming effects with just-in-time test data. No invasive scaffolding and test-only abstractions common in DI libs.
https://github.com/Alex-Ozun/swift-effect
@alexozun hey my friend @orj and I were looking and thinking that the SwiftUI environment is kind of like this too — but solves it in a very different way for a specific context. I was wondering if SwiftUI’s environment quite counts as ‘algebraic’ though… What are your thoughts?
@huwr @orj there are certainly similarities between SwiftUI env and algebraic effects. But the key diff is that SwiftUI env is basically a flavour of Service Locator DI, where you inject and retrieve instances from env. Whereas with algebraic effects we don't inject anything or retrieve instances at call sites. Instead, control flow is passed from call sites up to enclosing effect handlers (which can compose by passing control further up), enabling dynamic binding of behaviours.
@alexozun @orj okay yeah it’s that inversion I’ve not quite understood yet. Thanks!