Type Erasure

Sometimes it may be desirable to explicitly remove type information. Often this is when you want to pass around types with complicated generic signatures. SwiftCurrent, much like many of Apple’s standard libraries, ships with several type erasers for your convenience.


The type AnyWorkflow.PassedArgs is worth calling out separately. It’s very similar to Swift’s standard Optional type, but with a crucial difference. Consumers of SwiftCurrent need to be able to clearly differentiate between nil being passed in a Workflow that proceeded and no arguments being passed. So if a FlowRepresentable.WorkflowInput is Any?, that means it can accept any data, even if that data is optional, but data must be passed to it. If a FlowRepresentable.WorkflowInput is AnyWorkflow.PassedArgs, it means that it can take any data, including nil data, OR it can take no data at all.