-
Notifications
You must be signed in to change notification settings - Fork 49
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
RR Fetch Syntax #33
RR Fetch Syntax #33
Conversation
### error | ||
|
||
Errors can also be lifted to the Fetch monad via `exception.fetch`. Note that interpreting | ||
an errorful fetch to `Eval` will throw the exception so we won't do that: |
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.
In the case of Eval
it won't throw the exception unless accessing the value with .value
, maybe we can show how the exception is conveyed on the Xor.Left
when ussing the attempt
combinator?
Other than the comment LGTM, really awesome work 👍 |
Feel free to reword or remove that part for now if you want this to be included in the release.I won't be close to a computer this evening |
All right, i'll edit that part and cut another release with the new syntax and docs. |
The following PR provides implicit syntax to lift any
A
toFetch[A]
as well as syntax for the most useful combinators on aFetch[A]
.@dialelo @rafaparadela Can you please review? Thanks!
Pseudo extract from the included docs contribution:
Syntax
Implicit syntax
Fetch provides implicit syntax to lift any value to the context of a
Fetch
in addition to the most common used combinators active withinFetch
instances.pure
Plain values can be lifted to the Fetch monad with
value.fetch
:Executing a pure fetch doesn't query any data source, as expected.
error
Errors can also be lifted to the Fetch monad via
exception.fetch
. Note that interpretingan errorful fetch to
Eval
will throw the exception so we won't do that:join
We can compose two independent fetches with
fetch1.join(fetch2)
.If the fetches are to the same data source they will be batched; if they aren't, they will be evaluated at the same time.
runA
Run directly any fetch to a target any target
Monad
with aMonadError
instance in scopefetch1.runA[Eval]
.runE
Extract a fetch an get it's runtime environment
fetch1.runE[Eval]
.runF
Run a fetch obtaining the environment and final value
fetch1.runF[Eval]
.