Jannis
02/22/2019, 8:49 PM@extension
here does not work?
@higherkind
class Test<A>(val f: () -> A): TestOf<A> {
companion object {}
}
@extension
interface TestFunctor : Functor<ForTest> {
override fun <A, B> Kind<ForTest, A>.map(f: (A) -> B): Kind<ForTest, B> =
Test { f(fix().f()) }
}
This fails with kaptKotlin
reporting `e: error: Arrow's annotations can only be used on Kotlin classes. Not valid for error.NonExistentClass``But aren't pretty much all instance declared this way? What am I missing here?pakoito
02/23/2019, 1:05 AMHexa
02/24/2019, 9:05 AMtry catch
override fun f1(): Either<Errors.ApplicationError, AWSClient> =
Try {
try {
// logic1 here
} catch (ex: Exception) {
// if logic1 throws exception then try logic2 in here
}
}.toEither().mapLeft {
(Errors.UnexpectedError("Unexpected error: ${it}"))
}
zsmb
02/24/2019, 5:59 PMinterface Eq<F> {
fun F.eqv(b: F): Boolean
fun F.neqv(b: F): Boolean = !eqv(b)
}
data class User(val id: Int) {
companion object
}
@extension interface UserEq : Eq<User> {
override fun User.eqv(b: User): Boolean = id == b.id
}
Now, I can make the neqv
call work, as that extension is generated:
val user1 = User(1)
val user2 = User(2)
user1.neqv(user2)
However, I don't get an eqv
extension generated. I did get an eq
extension that I could then open a scope on with run
, but this isn't very neat:
User.eq().run {
user1.eqv(user2)
}
So... Is there something I could fix in my code to make Arrow generate the eqv
extension that I could use like this?
user1.eqv(user2) // right now, unresolved reference: eqv
pakoito
02/26/2019, 3:55 PMImran/Malic
02/26/2019, 5:23 PMsimon.vergauwen
02/28/2019, 8:06 AMpakoito
03/01/2019, 10:15 PMraulraja
03/01/2019, 10:59 PMfx
in 0.9.0raulraja
03/02/2019, 1:03 PMfxCancellable
if you wish to obtain a cancel token alongside your program:raulraja
03/02/2019, 1:04 PMHieiJ
03/04/2019, 9:30 PMreik.schatz
03/05/2019, 2:37 PMfun foo(): Try<Unit> {
return Try {
1 // doesn't compile
}
}
sitepodmatt
03/06/2019, 4:09 PMpakoito
03/08/2019, 1:17 PMraulraja
03/09/2019, 5:39 PMstojan
03/10/2019, 6:01 PMbind()
still works 🙂stojan
03/10/2019, 6:39 PMDanilo Herrera
03/11/2019, 6:04 PMsealed class Cargo<T> {
class Loading<T> : Cargo<T>()
data class Loaded<T>(val cargo: T) : Cargo<T>()
data class Error<T>(val cargo: T) : Cargo<T>()
}
raulraja
03/12/2019, 4:16 PMjanvladimirmostert
03/13/2019, 12:46 PMHexa
03/15/2019, 3:30 PMoverride fun getCar(name: String): Either<CarNotFound, String?> {
val carAttributes = loadCarAttributes(name)
return when (carAttributes) {
is Either.Right -> {
return Right(carAttributes.b.attributes["carId"])
}
is Either.Left -> {
Left(CarNotFound("car not found"))
}
}
}
When I call that function I want to access the values so that if the value is Left then I just return CarNotFound to the client.
Else I use the value on the Right (which is just a string) to do further processing. I tried something like this but it didnt't work
val carType = getCar("testname").fold(
return Left({CarNotFound(it.message)}),
{it})
)
Bob Glamm
03/18/2019, 7:55 PMjeremy
03/20/2019, 1:11 AMearroyoron
03/20/2019, 8:59 AMBob Glamm
03/20/2019, 1:27 PMJannis
03/25/2019, 2:28 PM(a -> b) -> (c -> d) -> p a c -> p b d
and arrow fun <A, B, C, D> Kind2<F, A, B>.bimap(fl: (A) -> C, fr: (B) -> D): Kind2<F, C, D>
. So the intuition is its basically a functor applied to both type arguments. Fold looks more like this (for option): (() -> b) -> (a -> B) -> Maybe a -> b
fun <A, B>Option<A>.fold(none: () -> B, some: (A) -> B): B
and either is similar. Fold destructures while bimap keeps structure. If you are looking for types that are bifunctors and their uses: Either
has a bifunctor instance, Ior
should have one and I think soon we'll have IO
be parameterized to IO<E, A>
and that should be a bifunctor as wellFabian
03/26/2019, 8:38 AMFixed in #40😢
carlos cdmp
03/28/2019, 10:15 AMval (resultKind, disposable) =
fxCancellable {
getAllCharactersCase.execute()
}
myDisposable = disposable
val result: Try<CharacterList> = ...
result.fold(
ifFailure = {
println(it.message)
},
ifSuccess = {
displayResult(it)
}
)
raulraja
03/28/2019, 10:35 AMraulraja
03/28/2019, 10:35 AMcarlos cdmp
03/28/2019, 10:39 AMraulraja
03/28/2019, 10:41 AMMonadDefer
capable data type like Observable, etc