addamsson
10/19/2020, 4:24 PMPueffl
10/19/2020, 6:17 PMapply(plugin: "kotlin")
apply(plugin: "kotlin-kapt")
sourceCompatibility = "8"
targetCompatibility = "8"
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin")
implementation("io.arrow-kt:arrow-core:$versions.arrow")
implementation("io.arrow-kt:arrow-fx:$versions.arrow")
testImplementation("junit:junit:4.13")
testImplementation("com.google.truth:truth:$versions.truth")
testImplementation("io.mockk:mockk:$versions.mockk")
}
This is compilable, but when I try to run a Test, I get the following exception:
e: C:\Development\Projects\test\eight\android\domain\src\test\kotlin\com\eight\domain\simple\EmailAddressTest.kt: (16, 20): Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
Adding support for Java 8 language features could solve this issue.
Change Java language level and jvmTarget to 8 in all modules if using a lower level.
More information...Scott Christopher
10/20/2020, 5:03 AMeither.eager {...}
seems to need explicit type arguments, while either {...}
does not.
e.g.
fun fn(): Either<Throwable, Boolean> = TODO()
suspend fun example() {
either.eager<Throwable, Boolean> {
val a = !fn()
val b = !fn()
a && b
}
either {
val a = !fn()
val b = !fn()
a && b
}
}
tim
10/21/2020, 12:57 PMDuplicate JVM class name
error after moving to arrow 0.11.0 and Kotlin 1.4.10 when using optics. As far as I can tell this is similar to the issue @Joram Visser raised here except in my case I'm using gradle not maven.
I'm struggling to debug this, because optics are compiling correctly elsewhere in the same project, and it just seems to be one data class that is now causing this error. I tried creating a new repo and reproducing but it compiles and run fine.
Any suggestions on how to approach debugging this?pakoito
10/24/2020, 5:38 PMunwrapBody
is what you’re afterdephinera
10/24/2020, 6:55 PMEither.ifRight { rightValue -> ... }
extension? Is this an antipattern?Big Chungus
10/24/2020, 7:13 PMpakoito
10/24/2020, 7:25 PMmap
and instead of returning a value, do a side-effect that returns `Unit`inside. It’s not a good pattern but that fits every use case for ifRight
Petr Makagon
10/26/2020, 2:58 AMSrki Rakic
10/26/2020, 10:39 AMfun <A> policy() =
Schedule.exponential<A>(100.milliseconds)
.whileOutput { it.millis < 1000 }
.or(Schedule.recurs(3))
What am I doing wrong here?hhariri
10/28/2020, 3:56 PMTwoClocks
10/30/2020, 2:55 AMfold
over the stream of msgs and my state lives in the fold? How can anything external to the fold access it?
2. How do you manage the IO, it's basically almost all IO w/ a small state-machine in the middle
This is a pretty typical pattern for the finical markets.CLOVIS
10/31/2020, 6:07 PMEither
...), I'm wondering how I could go around to make it ‘more functional'. I see that functions that return flows are better than simple suspend functions returning a list because the side effect doesn't happen during the function execution but is ‘stored' within the type.
I don't really see a way to do the same with ‘action' requests, apart from returning a Flow with a single value (or would you say that's good code?) If I understand, that's what IO
was for, but since it seems like it has been replaced by arrow-fx-coroutines
, I'd rather learn the ‘new version'
The other problem is the user interaction: currently, the user interaction consists of a few suspend functions that are called deeply inside the program. This way, it's not really possible for the ‘client' of the application to use a different UI. Usually this would be solved with Dependency Injection, but the Arrow wiki implies Typeclasses can assume that role in a better way.
Essentially, which steps would you take to change the architecture of this application so it's more functional? This particular project only runs on the JVM, if that changes anything, but I'd like to learn about techniques that work everywhere if that's possible. I've already went through and made all objects immutable, which should make the translation easier?carbaj0
11/01/2020, 7:16 AMfun <A, B> A?.toEither(error: () -> B): Either<B, A> =
this?.right() ?: error().left()
Karsten Gebbert
11/01/2020, 9:42 AMFree
for a small test, and I'm basically following along this example in the tests:
https://github.com/arrow-kt/arrow-incubator/blob/master/arrow-free-data/src/test/kotlin/arrow/free/FreeTest.kt
My questions are these:
• where does .fix()
"come from", i.e. which import am I missing?
• 'fx: MonadFx<FreePartialOf<ForProgram> /* = Kind<ForFree, ForProgram> */>' is deprecated. Fx will be moved to each datatype as a DSL constructor.
<- how to deal with this?carbaj0
11/01/2020, 11:10 AMDavide Bertola
11/02/2020, 8:08 AMDavide Bertola
11/02/2020, 4:25 PMTwoClocks
11/02/2020, 8:40 PMdavec
11/04/2020, 3:22 PM0.11.0
(or 1.1.0-SNAPSHOT
) is there any migration guide for what has changed (https://arrow-kt.io/docs/next/fx/ is not what I'm looking for, I am looking for a comparison of how things were done in previous releases versus 0.11.0
).
Along with that, are there any actual code examples for the 0.11.0 / 1.1.0-SNAPSHOT releases? Again, I don't want https://arrow-kt.io/docs/next/fx/ as there are no code samples of how to do monad comprehensions, as an example.
For example, take this example from @mattmoore’s blog post https://lambda.show/blog/arrow-io-monad-comprehensions-cleaner-monadic-composition... what's the equivalent syntax of this?
fun getAddressFromOrder(orderId: Int) = IO.fx {
val order = !getOrder(orderId)
val customer = !getCustomer(order.customerId)
val address = !getAddress(customer.addressId)
address
}
davec
11/04/2020, 3:24 PM0.11.0
(not older versions) other than the (very spare) Arrow docs?davec
11/04/2020, 3:30 PMobobo
11/05/2020, 10:26 PMForkConnected
to start up fibers the correct abstraction?
I use Channels to have different Jobs communicate. Are queues used for a similar purpose as channels? Is there an equivalent to select
? In particular, I'd like have some behavior repeated periodically OR when a signal is received, whichever is first. Would I use a Race
with a Schedule
for that?Krystian Rybarczyk
11/06/2020, 3:08 PMhandleError
? I’m getting Suspension functions can be called only within coroutine body
😞pakoito
11/09/2020, 11:31 AMJohan Basson
11/10/2020, 6:19 AMmarc0der
11/12/2020, 10:31 PMST
, short for State Token, which is a type that encapsulates local memory mutation and isolates the outside world from it. ST
is also a Monad
, and works very similar to the State
monad.
In my code samples while working with ST
, I am ending up with gnarly nested flatMap
and map
sequences that seem so redundant and difficult to interpret for the reader.
I would love to replace these nested monstrosities with neat for comprehension fx
blocks, and I have been digging into the arrow source code to get some tips about how to achieve this. The problem is that adding fx
binding capabilities to my own data type seems way complicated. Is there an easy way to achieve this? (or at least a guide or tutorial that instructs how to go about equipping your own data types with fx
binding)?
Hoping that someone can advise or shed some light on this.
I really appreciate any help you can provide.stojan
11/15/2020, 5:06 PMIn Kotlin with suspenddoes that mean that:can safely be used to recover from exceptions. source: https://github.com/arrow-kt/arrow-fx/pull/169try/catch
val result: Int = try {
evalOn(BlockingI)) { mySuspendFun() }
} catch(t: Throwable) {
5
}
would work?Satyam Agarwal
11/15/2020, 8:47 PMevalOn
, and coroutineContexts
. Made 2 test files to show what is happening and what I expect.
https://github.com/satyamagarwal/arrow-issues/tree/master/src/test/kotlin/com/arrow/issues
Can any one help me please ? feel free to take a pull and test it out.Pedro Sena
11/17/2020, 8:23 PMsuspend
, is that correct ?
We are using grpc-kotlin
and it already converts everything to suspend
functions and I'm wondering if now is a good time to start migrating the codebase to use 0.10 or should I wait for 0.11 and potentially not even need to use IO
(if I understood it correctly ofc)Pedro Sena
11/17/2020, 8:23 PMsuspend
, is that correct ?
We are using grpc-kotlin
and it already converts everything to suspend
functions and I'm wondering if now is a good time to start migrating the codebase to use 0.10 or should I wait for 0.11 and potentially not even need to use IO
(if I understood it correctly ofc)Scott Christopher
11/18/2020, 12:14 AMshould I wait for 0.11Not sure if I have misunderstood, though v0.11 is the current stable release. I can't speak on behalf of the Arrow crew, though our team has decided to make full use of the suspend functionality in Arrow in v0.11 which so far is working really well. Most of what would've previously been functions returning
EitherT<ForIO, ServiceError, A>
are now simply suspend fn(): Either<ServiceError, A>
and making heavy use of either.fx
arrow-fx-coroutines
repo that compared the two previously, though it looks like it has since been repurposed for other content. The previous doc can still be accessed here: https://github.com/arrow-kt/arrow-fx/blob/ad96d2e8348bc56ad20e1014f0e9059622cd259d/arrow-fx-coroutines/README.MDraulraja
11/18/2020, 10:04 AMPedro Sena
11/18/2020, 11:50 AM