I hereby claim:
- I am chrisphelps on github.
- I am cjphelps (https://keybase.io/cjphelps) on keybase.
- I have a public key whose fingerprint is A077 D641 82C2 94A3 588C 44AE 585C 6AF1 721B B82C
To claim this, I am signing this object:
for { | |
config <- configServiceResponse | |
user <- userServiceResponse | |
prefs <- getPreferencesForUser(user, config) | |
items <- getItemsForUser(user).map{ item => personalizeItem(item, prefs) } | |
} yield format(items) |
public ListenableFuture<List<Item>> getUserItemsWithConfig(User user, ListenableFuture<Config> configFuture) { | |
// transform on configFuture and call getItems(user, config) | |
... | |
} | |
public List<Item> getItems(User user, Config config) { ... } | |
ListenableFuture<User> user = getUser(args); | |
final ListenableFuture<Config> config = getConfig(args); | |
ListenableFuture<List<Item>> items = Futures.transform(user, |
for { | |
config <- configServiceResponse | |
user <- userServiceResponse | |
items <- getItemsForUser(user) | |
prefs <- getPreferencesForUser(user, config) | |
personalized <- personalizeItems(items, prefs) | |
} yield format(personalized) |
implicit def toScalaFuture[T](lFuture: ListenableFuture[T]): Future[T] = { | |
val p = Promise[T] | |
Futures.addCallback(lFuture, | |
new FutureCallback[T] { | |
def onSuccess(result: T) = p.success(result) | |
def onFailure(t: Throwable) = p.failure(t) | |
}) | |
p.future | |
} |
ListenableFuture<User> user = getUser(args); | |
ListenableFuture<List<Item>> items = Futures.transform(user, | |
new AsyncFunction<User, List<Item>>() { | |
@Override | |
public ListenableFuture<List<Item>> apply(User user) throws Exception { | |
return getItemsForUser(user); | |
} | |
}); |
I hereby claim:
To claim this, I am signing this object:
class Foo (name: String) { | |
def apply() = "Foo " + name + "results" | |
} | |
class Bar(name: String) { | |
def apply()(implicit f: Foo) = "Bar" + name + "results: " + f() | |
} | |
class Baz { | |
implicit val myfoo = new Foo("production") |
f1 flatMap(a => for (b <- f2; c <- f3(b)) yield c * a) | |
f1 flatMap(a => f2 flatMap(b => for (c <- f3(b)) yield c * a)) | |
f1 flatMap(a => f2 flatMap(b => f3(b) map(c => c * a))) |
val f1 = future { 5 } | |
val f2 = future { "str" } | |
val f3 = (s: String) => future { s + "vap" } | |
val f4 = for { | |
a <- f1 | |
b <- f2 | |
c <- f3(b) | |
} yield c * a |