Why no scala.util.Try.eventually ?

357 views
Skip to first unread message

oxbow_lakes

unread,
Jul 30, 2013, 3:08:39 AM7/30/13
to scala...@googlegroups.com
On this thread (https://groups.google.com/forum/#!searchin/scala-user/Try$20and$20finally/scala-user/yrZ3Je63IiI/dXRqguYIxQIJ), Viktor displayed how you could add "evfentually" (basically a "finally" construct for Try) as follows:

implicit class TryOps[T](val t: Try[T]) extends AnyVal {
  def eventually[Ignore](effect: => Ignore): Try[T] = t.transform(_ => { effect; t }, _ => { effect; t })
}

This is great but the need for a "finally" for Try seems so fundamental, I can't understand why it's not just in the stdlib. I've done a bit of searching but can't find any place where this was previously discussed (i.e. a rationale for its exclusion). Any pointers?

Chris

oxbow_lakes

unread,
Jul 30, 2013, 5:02:18 AM7/30/13
to scala...@googlegroups.com
If it comes to that, there's no "fold" either, which seems rather mystifying given it was finally added to Option and it exists on Either

Chris

√iktor Ҡlang

unread,
Jul 30, 2013, 6:39:24 AM7/30/13
to oxbow_lakes, scala-user

Adding "andThen" on Try and "fold" on Future and Try would be useful.

Cheers,
V

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Simon Ochsenreither

unread,
Jul 30, 2013, 1:08:55 PM7/30/13
to scala...@googlegroups.com, oxbow_lakes
I'd be happy to review changes which make the API between Option/Try/Either more consistent!

I'm wondering whether it would make sense to have some interface to keep them from drifting apart?
Reply all
Reply to author
Forward
0 new messages