-
Notifications
You must be signed in to change notification settings - Fork 227
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
more in-depth README #62
Conversation
Make it fit on one line and fix the function name so it's consistent with the previous example
|
||
Swift 2.0 introduces error handling via throwing and catching `ErrorType`. `Result` accomplishes the same goal by encapsulating the result instead of hijacking control flow. The `Result` abstraction also enables powerful functionality such as `map` and `flatMap`. | ||
|
||
Since dealing with APIs that throw is common, you can convert functions such functions into a `Result` by using the `materialize` method. [Note: due to compiler issues, `materialize` is not currently available] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also note here that the opposite function (dematerialize
) is available to access the value or throw.
Alright. I made a couple edits based off suggestions. I also wonder if it might be worth mentioning things like what Argo is doing (except they are using their Decoded enum instead of |
Also, another idea: since one of the motives behind this lib is so that you can share a common Result type between modules, maybe it would be appropriate to mention a few popular libraries that use Result, such as ReactiveCocoa? |
👍 |
Good stuff!. I discovered this library through ReactiveCocoa 3.0 unit tests, so for me it would be even better with examples of tying in to that framework although i recognise it might seem premature, considering that it's just a development branch. But as @jarsen mentions it's great that you can share a common Result type between modules, so why not show it :) I agree that mentioning popular libraries that uses Result is a good idea. |
Any other popular libraries besides ReactiveCocoa we might use? |
Not sure if it classifies as popular, but I wouldn't mind if BrightFutures is mentioned. (Disclaimer: I'm the primary author of BrightFutures) I tried searching GitHub for occurrences of Result in Podfiles/Cartfiles, but did not run into any other libraries that I recognized. |
I think BrightFutures would be good to add 👍 |
bump @antitypical/result: Anything else we want to add or shall we merge this? |
|
||
## Result vs. Throws | ||
|
||
Swift 2.0 introduces error handling via throwing and catching `ErrorType`. `Result` accomplishes the same goal by encapsulating the result instead of hijacking control flow. The `Result` abstraction allows enables powerful functionality such as `map` and `flatMap`, making `Result` more composable than `throw`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstraction allows enables powerful
Few minor notes, but 👍 otherwise |
Or we could merge as-is and fix in a separate PR since this is rather old |
|
||
Other methods available for processing `Result` are detailed in the [API documentation](http://cocoadocs.org/docsets/Result/). | ||
|
||
## Result vs. Throws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth also mentioning that you can't use throws with asynchronous APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it'd be helpful to have more information here and possibly an example.
I’d be 👍 to that. |
I'm new to this project. I came to it through ReactiveCocoa and as I've been exploring I've been wondering where would I have a bit of time this week, would you like me to make the changes here to help get it shipped? @robrix @jarsen @neilpa I think that others would benefit from the information here not being locked up in a PR. |
Let’s merge this one as-is, and then you can open a PR off |
That sounds good |
This is my attempt to help out with #51.
I'm not sure how great my example is... but I think it does demonstrate the core concepts well. And it was the first example I thought of.
I also tried to give a shoutout to
map
andflatMap
, and a reference to Javi Soto's monads article (without mentioning the words Functor or Monad in the README). I'm not sure if this is a horrible idea. Seems like now that Swift 2.0 brings error handling the higher order functions are really what make results stand out as a better (IMO) solution to error handling. Since those features are one of the compelling reasons forResult
I thought it might be appropriate to highlight them a little.Anyway let me know what you think. Hopefully it's helpful.