<@U4UGS5FC7> serious? I have recently just managed...
# arrow
h
@raulraja serious? I have recently just managed to learn how Either, Try, Option and Validated works. Are you planning to deprecate all of them?
👌 1
@raulraja, thanks for clarifying. interesting! if it can do something big and different to Scala and Haskell then it can do everything😀
r
yes, we are in a different direction now following the philosophy that Kotlin already promotes of removing nesting
This is at the core of receiver and extension functions and it can also be in terms of data types that can be asimilated by lang features
For example Either is eliminated by union types and you gain arbitrary arity and exaustive match in all cases with automatic conversion to nullable types. This eliminates the need to use Left and Right to construct values of the union
so it treats Either the same way Kotlin treats Nullable types assimilating it’s syntax into the lang
same when we implicitly convert suspend to IO and back:
Copy code
val a: IO<A> = TODO()
suspend fun doInIO(): A = a //.suspended() is eliminated
Copy code
suspend foo(): A = IO.fx { a }
h
what's are the benefits of using union over either?
r
Leaner runtime, supports up to 22 args, eliminates the constructor syntax and accepts values of the union directly and converts to nullable values of the union directly . Can be derived from existing sealed hierarchies, etc.
👍 1
We will add proper docs when we finish the current prototype in meta
p
Have you a syntax to resolve ambiguities about creating Unions with same types (eg Union<A, A>) ?
r
That is equal to A by a type proof
It's not yet implemented though
Do you have an example of the ambiguity ?
p
Ok Union<A,A> is A. The ide plugins should propose this optimisation. Maybe, in case of duplicate type, you should return an error at the compilation level. Yeah, It's a good design to promote disjoint types 👍
Then, Union<A,B,A> will be Union<A,B> and so on... That's also mean that Union<A,B> will be equal to Union<B,A>. Is the case in Scala ?
r
Yes it's commutative
It's one of the laws
The type proof plugin already provides proofs for all positions of A in the union
👌 1
The type proof plugin proofs morphisms between types and can inject them for free with an inlined runtime
And selectively eliminate the syntax like in the case of unions where you have proofs for all A back to A? if anywhere present in the union
p
What about type alias ? eg, if we have A&B for C, what will be <A,B> ? A,B,C or you will preserve <A,B> ? I said that because if for any reason we have spaghetti types, it could be difficult to determine the common type; and, the resulting type could be ambiguous for the developper. point of view.
r
A Union<A, B> is a type alias for Union22<A, B, Any?, Any?…>
there is a single interface Union22 that eliminates the need to nest and recurse in the type checker
same for Kinds, and others
p
Ok thx for these explanations...
👍 1