Comments (6)
You would have the same problem with an Either
in a for
-comprehension (see this question on SO)
What you would need is return a Promise[Either[X,B]]
to make it possible to use and in case the predicate is not respected, return a Left(??)
. However, in the general case you have no clue how to build the Left
element.
This was made possible in scala 2.10 with scala.util.Try
because we know how to build the failure case (see here).
It would be really useful for one of my projects to be able to filter on the result :-)
from reboot.
As long as dispatch supports versions prior to 2.10, we probably won't be rolling in language features specific to 2.10 but I may be wrong ( @n8han ?) I think there was some work being done to work in scala 2.10 futures/promises or at least to an attempt to make dispatches language for the 2 in-line with the ones scala recently introduced. Note on that, @n8han's work on reboot predated those. Scala's either projects define a filter so I started a branch to do the same in dispatch. This is where I left off. I haven't had time to follow up on it but I'll have a look at your link above.
from reboot.
The futures API was backported for 2.9.3 so i believe it would include Try.
from reboot.
@n8han That's right, Try
exists in 2.9.3
@softprops I know filter
method exists for Either
projections, and my link is about it. It does not work in for-comprehensions either and cannot work this way. You would have to use the trick of going to an option and then calling toRight
on it (in the answers on my SO link).
from reboot.
My impression from reading this issue is that this isn't something that's still a problem given that we dropped support for older Scala versions, but I could be wrong about that. I'll leave it unlabeled for now as a signal to myself to investigate further. If someone could validate my understanding I could just close this issue.
from reboot.
Just confirmed this is still an issue as written, but that seems to be because of the conflation of Future
and Either
, which I'm not sure should be supported in any event. FWIW, Scala 2.12 introduced toTry
on Either
that allows something like this:
@ for { result <- Http(req > as.lift.Json).either } yield {
for ( JObject(fs) <- result.toTry ) yield fs
}
res8: Future[scala.util.Try[List[JField]]] = Future(<not completed>)
@ res8.value
res9: Option[scala.util.Try[scala.util.Try[List[JField]]]] = Some(
Success(
Success(
List(
JField("details", JString("API requests must be key-signed, oauth-signed, or accompanied by a key: https://www.meetup.com/meetup_api/docs/#authentication")),
JField("code", JString("not_authorized")),
JField("problem", JString("You are not authorized to make that request"))
)
)
)
)
To that end, since we no longer support < 2.11, we should probably expose a helper to provide a Try
instead of an Either
if that's what folks want in their code.
I'm going to close this issue and open a new ticket for Try
support from the execution system. Let me know if there are any concerns with this resolution.
from reboot.
Related Issues (20)
- Updating from 0.8 to 0.13 HOT 5
- Upgrade lift-json module for Lift 3.1.0
- Provide plain-english alternatives to every method in the symbolic DSL
- Bump to AHC to 2.0.33
- Possible domain / group id change HOT 4
- Implement implicit vs explicit verb setting
- Cross-build / abstract against AHC HOT 1
- Investigate different thread allocation semantics under the hood
- Please publish a version for Scala 2.13.0-RC1 HOT 15
- sbt eviction notice HOT 1
- Incorrect UriEncoding of emoji characters HOT 1
- setting request body with << changes method from PUT to POST HOT 6
- Requesting URLs with custom parameters is not possible HOT 6
- Emoji character in domains not recognized correctly (punycode) HOT 1
- Emoji character in domains not recognized correctly (punycode) HOT 8
- Rename primary branch HOT 1
- Add support for Scala 2.13 HOT 1
- Add support for Dotty HOT 5
- Update scala-xml dependency to version 2
- Set up dependency update for this repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reboot.