Hi all! I have a question about the new union type...
# arrow
m
Hi all! I have a question about the new union types: will arrow completely do away with
Option
and
Either
in the future, or will they co-exist with unions?
k
if they are isomorphic we could replace Option<A> with it’s equivalent A? as compiler plugin to dismiss the boxing.
m
Thanks @raulraja, that makes perfect sense. I'm busy revisiting the earlier chapters of the book to make sure that I'm aligned with what arrow is offering in the future. Stripping out the all references to
Try
too.
I'll still teach how to build
Option
from first principals because it teaches a valuable lesson. When Arrow removes
Option
officially, I'll go back and makes mention of the way arrow handles nullable types to get the same effect. Personally, I'm not a big fan of the nullable types and like the good old (explicit)
Option
😛
I'm just an old Scala dude hehehe
r
yeah, we may not remove Option, there isn’t really anything wrong with it if some people prefer that style and it would help people from Scala as well but we will make explicit that nullable types is the way to go.
m
you would make me very happy by keeping it 😄
But I'll certainly make mention of the nullable types in a sidebar when you roll that out.
👍 1
r
The issue we did not keep Try was because it was promoting bad practices like performing effects in place but in the case of Option it’s only problem is that it’s slower and more memory intensive than ? but most users are not in hot spots where that matters to them
m
Yeah very true, and also I get that
Try
is bad news. I've personally been using cats effect in Scala for some time now. Love it.
j
I have a usecase where i was using something like Either<TextTransform,BinTransform>.fold({},{}) and occasionally wanted to return result that was left(left()) or right(right()). The instantiation of that outcome seemed to defy available factory methods so i scrapped that. Union<A,B> is the abstraction I want here to stack unary operators ?
r
j
so val coin:Either <Head,Tails> has equal options for reight and left? i wasn't finding it the first time.
r
yes, although the most common ones like map, flatMap, etc are right biased.
It’s also a bifunctor, etc so you can bimap over both sides at once
j
message has been deleted