swift-overture
swift-overture copied to clipboard
Potentially add `rethrows` to `over` and similar functions
Context
I'm trying to update some code that I think could really benefit from a functional style. Here's the current code:
let keyPaths: [WritableKeyPath<Config, String>] // ...
for keyPath in keyPaths {
config[keyPath: keyPath] = try evaluator.evaluateExpression(config[keyPath: keyPath])
}
The problem
I've tried a few different approaches and none of them compile because evaluateExpression is a throwing function, and the overture functions I'm trying to use don't have rethrows. Here's my best attempt:
let evaluators = keyPaths.map { over($0, evaluator.evaluateExpression) }
for evaluateField in evaluators {
config = try evaluateField(config)
}
Potential solutions
- I'm missing something and there's a better way to do this with a function that does have
rethrows - Add
rethrowsto all of the methods except where it doesn't make sense (I feel likeoverand co make sense to haverethrows)