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
Handle different shapes/styles of success & failure tuples #27
Comments
At the moment that their are no plans to accept different shapes of success. There are some reason's which were discussed in another issue that I can't find right now. @bill-mybiz might remember where? It boils down to that fact that other shapes can't be handled as a result monad an binding becomes ambiguous. It might be helpful if you could be more concrete in what you want to achieve, problems you are facing. |
Hmm, there are a couple aspects to this that come to mind:
As for (1), I remember this thread on EF. I think we also mentioned it briefly elsewhere, and I know we talked about the shape of the As for (2), we recently mentioned this in #5, as I mentioned it would be very useful for integrating with third-party libs - but with regard to the return value not requiring the shape of the ok result monad. Phoenix channels is what comes to mind for me personally. As for (3), I'm still unsure of the value of this concretely, but it sounds related, since @seivan is talking about different types of successes? I take this to be the implementation details of the success of a third-party call, and so I would agree that it may be fruitful to have a concrete example, with the lib and the shape(s)? ❓ As for the capturing exceptions and treating them as error monads, I definitely think that would be a great feature and I think this is captured in issue #12 "options for with", i.e. pure vs. complete. I'm still unsure of the precise intended verbiage there, but I think that discussion would be best continued there. 👍 |
Clarification: I'm unsure of the inherent value of |
@bill-mybiz I didn't quite understand your first point but I'll try to respond to the two other ones.
What I'm essentially looking for is an static fileprivate func parseYAML(fromFileContent fileContent:FileSystemLoader.FileContent<String>) throws -> Parser.UnfilteredContent {
return try Either<Error, FileSystemLoader.FileContent<String>>
.right(fileContent)
.map { $0.content }
.map(Yaml.yamlObject)
.map { FileSystemLoader.FileContent(with: (raw:fileContent.content, processed:$0), from: fileContent.file) }
.unwrapError()
} I shouldn't have to concern myself of the variations of success or failure patterns that each third party library returns if I want to join them together. I mean, I was hoping this library would take care of that concern for me, but I understand if it's an unreasonable expectation. I'm just looking to see what's possible. Is that an unreasonable request? My macro-fu isn't so strong, but I would assume there would a way to manage expectations. |
@CrowdHailer The problems I'm facing is the various patterns of results or failure not to mention exceptions from methods that might throw/raise but aren't indicated to do so. Usually those are related to modules that work with third party services (like redis or sql) where it can throw even though the method isn't supposed to because of something underlying breaking. To quote myself from previous comment:
|
Also want to point out that if your value doesn't match the next function in the pipe, you'll get an exception and will have no idea why.
It would be nice if OK could handle that. So I could have the Railway orienteded path. |
@seivan You've cleared up for me what exactly you're looking for. 😄 This is what I was talking about with point 1, which is describing the expected shape of the happy path result when using the For your given specific example of returning OK.with do
"OK" <- {:ok, Pi.set}
value = Pi.get
...
end Notice that third-party lib's return value That said, I looked through that entire lib and from what I grokked, it isn't amenable to a happy path style of coding. This can be seen from the fact that there are zero native
I'm not sure how this would be accomplished without someone knowing the specific details on the variations of success/failure. This is, AFAICT, why the As for catching exceptions, there is a new issue #28 which speaks to this, and also the other issue I mentioned #12 "options for with". As I mentioned there, I think it may possibly be nice syntactic sugar for |
closing as I don't think that it is write for this library to start handling other tuple shapes. particularly as if a user is finding that is the case they can always fall back to native with |
@CrowdHailer I still think there is room, especially when dealing with a lot of third party code that follow different standards (e.x |
I think you might need to wait for Elixir to have a type system to see those but here's hoping. I think they would be good additions |
It would be great if we could capture different types of successes from various third party libraries as well as the failures that can occurs.
Not everything is shaped
{:ok, value}
and it would be awesome to get to see that normalised to common ones as well as capturing exceptions and treating them as errors.Edit:
From the looks of it, I'd assume it would be adding multiple version of
bind
for different 'shapes'Just shooting from the hip.
The text was updated successfully, but these errors were encountered: