Open oscbyspro opened 1 week ago
I stumbled upon this ceremony while working on composable (#126) algorithms:
func algorithm<T>(_ value: consuming T) -> Fallible<T> { var error: Bool = false value = foo(value).sink(&error) value = bar(value).sink(&error) value = baz(value).sink(&error) return Fallible(value, error: error) }
It isn't terrible, but a Fallible.sink(_:performing:) is perhaps more ergonomic:
Fallible.sink(_:performing:)
func algorithm<T>(_ value: consuming T) -> Fallible<T> { Fallible.sink(consume value) { value, error in value = foo(value).sink(&error) value = bar(value).sink(&error) value = baz(value).sink(&error) } }
I stumbled upon this ceremony while working on composable (#126) algorithms:
It isn't terrible, but a
Fallible.sink(_:performing:)
is perhaps more ergonomic: