Alexander Levin
10/05/2021, 6:15 PMConst
assuming we don't have HKT simulation anymore?
• Same question for widen
(code examples seems to be working just fine without widen
call)
• Is there a reason to implement most functions inside of Either/Validated/etc or is it just the matter of preference? (I think standard library usually extract non-essential functions as extensions as much as it's possible considering interop)
• Is there any code examples about using Arrow with any popular framework/library like Ktor or Spring?
• What's the usage of Endo
? (didn't really find it in the repo)simon.vergauwen
10/07/2021, 1:13 PMsimon.vergauwen
10/07/2021, 1:14 PMConst
away in Arrow, so this data type is probably the most likely to be up for deprecation towards 2.0.
It’s possible to use Const
, for type tagging but there are other concrete options that typically for fine in most occasions.simon.vergauwen
10/07/2021, 1:15 PMwiden
is still useful to upcast the type.
Either<Error, Int> -> Either<Error, Number>
simon.vergauwen
10/07/2021, 1:16 PMsimon.vergauwen
10/07/2021, 1:18 PMEither
that are implemented as extension functions is because the generics are defined as out
, and we need to re-capture the generic to ignore the out
restriction.simon.vergauwen
10/07/2021, 1:18 PMsimon.vergauwen
10/07/2021, 1:19 PMEndo
is a type meant for Monoid
to compose functions.Alexander Levin
10/11/2021, 10:28 AMis still useful to upcast the type.widen
Either<Error, Int> -> Either<Error, Number>Maybe I am missing something but looks like it works out of the box without
widen
call:
val either: Either<Error, Int> = Either.Right(123)
val widened: Either<Error, Number> = either
simon.vergauwen
10/11/2021, 4:41 PMfold(either.widen<Number>()) { acc, n -> }
Here is a case where you need widen
, but I must admit the cases are very rare. In some cases they can indeed also we replaced by explicitly recapturing in a val
with a different type. That’s also the implementation of the widen
function.