That's a good point - I could map to an exception like that. I assume you
mean the algebra of the reply message from the look up actor:

trait UserInfo
case class AvailableUserInfo(firstName:String, lastName:String)
case object MissingUserInfo

That's an interesting idea too. Thanks.


On Sun, Jun 29, 2014 at 6:55 AM, √iktor Ҡlang <viktor.kl...@gmail.com>
wrote:

> Hi Richard,
>
> since you are using Futures you'll have to deal with the case where the
> Future fails anyway, so why not represent the failed lookup as a
> NoSuchElementException? It's either that or expose the absence of value in
> the algebra (which I'd prefer).
>
>
> On Sun, Jun 29, 2014 at 3:40 PM, Richard Rodseth <rrods...@gmail.com>
> wrote:
>
>> Hi Viktor
>>
>> The use case is an actor that processes "commands", creating "jobs". But
>> first it has to look up something in the database to send to the job along
>> with the other job parameters. The Option comes from the fact that the
>> thing being looked up may not exist.
>>
>> As I mentioned, I first mapped the Future[Option[T]} to something like
>> Future[JobMessage]. It worked out quite well in this case, I thought, and I
>> have all the context I need in the Jobmessage I create. As an aside, I'm
>> tempted to say one should almost always pipe to self, so that the actor
>> doing the piping can handle the akka.actor.Status.Failure
>>
>> That said, if there are other suggestions for ways to unwind
>> Future[Option], I'm all ears.
>>
>>
>> On Sun, Jun 29, 2014 at 6:26 AM, √iktor Ҡlang <viktor.kl...@gmail.com>
>> wrote:
>>
>>> `Future[Option[T]] pipeTo self` sounds like a bad idea because there is
>>> no context to the message for the actor (it just gets a None, it doesn't
>>> even know what Option[T] it was since the T is erased.)
>>>
>>> What's the use-case?
>>>
>>>
>>> On Sun, Jun 29, 2014 at 3:34 AM, Richard Rodseth <rrods...@gmail.com>
>>> wrote:
>>>
>>>> So I've run into the "Monads don't compose" problem and am a bit
>>>> reluctant to tackle monad transformers and Scalaz at this point.
>>>>
>>>> I'm wondering what you all think about mapping the Future[Option[T]} to
>>>> something like Future[MyMessageType]  , piping to self, and then pattern
>>>> matching on MyMessageType in the receive handler, forwarding to the
>>>> ultimate destination or handling the error case as needed.
>>>>
>>>> --
>>>> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to akka-user@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> √
>>>
>>> --
>>> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
>>> To post to this group, send email to akka-user@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Cheers,
> √
>
> --
> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to