Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially add rethrows to over and similar functions #72

Open
stackotter opened this issue Mar 4, 2022 · 0 comments
Open

Potentially add rethrows to over and similar functions #72

stackotter opened this issue Mar 4, 2022 · 0 comments

Comments

@stackotter
Copy link

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

  1. I'm missing something and there's a better way to do this with a function that does have rethrows
  2. Add rethrows to all of the methods except where it doesn't make sense (I feel like over and co make sense to have rethrows)
@stackotter stackotter changed the title Potentially add throwing regrows to over and similar functions Potentially add regrows to over and similar functions Mar 4, 2022
@stackotter stackotter changed the title Potentially add regrows to over and similar functions Potentially add rethrows to over and similar functions Mar 4, 2022
@stackotter stackotter changed the title Potentially add rethrows to over and similar functions Potentially add rethrows to over and similar functions Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant