2012年8月26日

# scala.util.Try

まとめました。
4

OH: "wow, scala.util.Try is really bad" Yes it sure is all L3 and everything. /cc @gersei

Just learned that #scala.util.Try is spectacularly bad, not just bad. Is this why twitter's errors suck balls?

@dibblego Oh wow. I didn't realize how dangerous it was until just now. I guess reliable/consistent behavior is just for us neckbeards.

@purefn If you think scala.util.Try is dangerous, wait until you see the #scala mailing lists! Morans iz dangerouz.

OH: "the biggest travesty of scala.util.Try is... endorsed by people... know better, so that people that are new will not learn properly"

@dibblego In what way is it worse than you already believed? I'm extremely curious now...

@mergeconflict see map and flatMap for spectacularly dangerous law-breaking.

@dibblego hmm, has somebody written at length about this yet? i'm tempted.

@mergeconflict No, but others have suggested I do (I don't know if I get a chance). I argued that it will fall on the usual deaf ears, ...

@mergeconflict ..it was counter-argued that at least for the purposes of learning and discussion for those who are open to it -- I agree.

@dibblego the worst case I'm seeing here is the composition law for functors: Success(a) map { f compose g } != Success(a) map g map f

@mergeconflict Discussing on IRC at the moment -- it's a tad more complicated (depends on how you define equality).

@mergeconflict forall x f. (x map f).isSuccess == x.isSuccess // false

@mergeconflict unless of course, you redefine identity, in which case, you've not satisfied the functor laws -- equivocation all the way.

@dibblego what server / channel

@mergeconflict irc://# Also the #scala channel, but it also gets ridiculous and very often so YMMV.

Well, I filed a bug on #scala.util.Try: https://t.co/QuFZlWyK. Now what do I win?

@mergeconflict with a response now. You don't have to limit your math to one category. It is flexible,

@dibblego @mergeconflict you can also redefine the initial category not to include arrows that catch stuff.

@dibblego @mergeconflict which is the intent of try. Don't use it if you want your arrows catching exceptions.

@jsuereth @mergeconflict I think more accurate is, "don't use it if you want your program to work."

@dibblego @mergeconflict doesn't it flat out break the left identity law by catching exceptions in binds?

@dibblego @mergeconflict to be fair, I feel that way about exceptions. Would rather see types encode possible failures.

@jsuereth @mergeconflict Sorry, but scala.util.Try is a total write-off and should never be used in my opinion.

@dibblego @mergeconflict isn't that your opinion of scala now, too?

### コメント

コメントがまだありません。感想を最初に伝えてみませんか？