Hi Jeff,
your API seems quite complex. I don't know the purpose of it so I cannot
suggest anything but I'd try to simplify. :)
That said, your problem seems to be that you cannot write a concrete type
that would express the dependency between the two components of the tuple
`(RequestBuilder, Promise[???])`. There are two ways to solve it:
1) make `Out` a type parameter and convert `sink` to a `def sink[Out]`,
then you can use the tuple `(RequestBuilder[Out], Promise[Out])`
2) create your custom tuple type that allows to express the dependency:
case class BuilderWithPromise[O](builder: RequestBuilder { type Out = O },
promise: Promise[O])
and then use it as MergeHub.source[BuilderWithPromise[_]]
But I can only repeat that getting rid of the dependent types if possible
is usually the best solution ;)
Johannes
On Thursday, July 6, 2017 at 11:23:50 PM UTC+2, Jeff wrote:
>
> Here is a strawman program which illustrates the issue I am having
>
> trait RequestBuilder {
> type Out
>
> def complete(p: Promise[Out]): Unit
> }
>
> def makeRequest(in: RequestBuilder): Source[(RequestBuilder,
> Promise[in.Out]), Future[in.Out]] = {
> val p = Promise[in.Out]
>
> Source.single(in -> p).mapMaterializedValue(_ => p.future)
> }
>
> val sink = MergeHub.source[(RequestBuilder, Promise[???])].to(Sink.foreach {
> case (r, p) => r.complete(p)
> }).run()
>
> sink.runWith(makeRequest(new RequestBuilder {
> type Out = Int
>
> def complete(p: Promise[Out]): Unit = p.success(1)
> }))
>
>
> The issue is, how do I type the Promise[???] in the sink? I have been
> able to work around this by making the Promise a part of the RequestBuilder
> trait itself, but this seems like a code smell to me
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.