Marius Kotsbak
11/19/2020, 1:21 PMCLOVIS
11/19/2020, 8:10 PMDavide Bertola
11/20/2020, 8:24 PMCLOVIS
11/21/2020, 6:31 PMFlow<Either<ErrorType, SuccessType>>
? Is there a specific type for this, or is it fine?Petr Makagon
11/23/2020, 3:22 AMjava.lang.IllegalStateException: No further work to do but also no result!
at arrow.continuations.generic.DelimContScope.invoke(DelimContScope.kt:96)
at arrow.continuations.generic.DelimContScope$Companion.reset(DelimContScope.kt:120)
at arrow.core.computations.either.invoke(either.kt:27)
Jörg Winter
11/25/2020, 5:03 PMMarko Novakovic
11/25/2020, 11:03 PM@Given
dependency injection with Arrow Meta? Follow implementation steps but am getting Gradle errors. https://github.com/arrow-kt/arrow-meta-examplessimon.vergauwen
11/27/2020, 3:55 PMaddamsson
11/28/2020, 10:03 PMaddamsson
11/28/2020, 10:09 PMdata class User(name: String = "", age: Int = -1)
that's an "empty" container and i can add to it with copy(name="xul")
addamsson
11/28/2020, 10:10 PMUser
took a Map
and i'd delegate `User`s fields to the Map
Satyam Agarwal
11/29/2020, 9:48 AMeither {
val (value1, value2) = parTupleN(
suspend { someMethodReturningEither() },
suspend { someMethodReturningEither() }
)
.right()
.flatMap { (first, second) -> first.mproduct { second } }
.bind()
val (value1, value2) = parTupleN(
suspend { someMethodReturningEither().bind() },
suspend { someMethodReturningEither().bind() }
)
}
Is there a difference between the two in terms of how parallelism will be done ?
This question is because how I was used to do parTupledN
with IO
.
There the results were always flatMapped and used to give IO<Tuple2<A, B>>
Daniel Ryan
12/07/2020, 1:36 PMinternal fun polygonStringToPolygon(polygonString: String): Either<String, Polygon> {
fun collectResults(
results: Iterable<MatchResult>,
acc: MutableList<Position> = mutableListOf()
): Either<String, List<Position>> {
if (results.none()) {
return Either.right(acc.toList())
}
val (match, rest) = results.splitAt(1)
val x = match.single().groupValues.getOrNull(1)?.toDoubleOrNull()
val y = match.single().groupValues.getOrNull(2)?.toDoubleOrNull()
return if (x == null || y == null) {
Either.left("Unable to parse polygon")
} else {
acc.add(Position(x, y))
collectResults(rest, acc)
}
}
val regex = "\\[([0-9]*.[0-9]*),([0-9]*.[0-9]*)]".toRegex()
val matchResult = regex.findAll(polygonString)
return collectResults(matchResult.asIterable())
}
Jörg Winter
12/07/2020, 5:21 PMfun f1() = Either.right("Ok")
fun f2(message: String): Either<String, String> {
return if (message == "Ok")
Either.right("totally Ok")
else
Either.left("Not Ok")
}
suspend fun main() {
either {
val r1 = f1().bind()
val r2 = f2(r1).bind()
println(r2)
}
}
I am getting this compiler error:
File being compiled: (9,1) in /home/jw/KotlinProjects/kalidation/src/main/kotlin/test.kt
The root cause java.lang.IllegalStateException was thrown at: org.jetbrains.kotlin.codegen.state.KotlinTypeMapper$typeMappingConfiguration$1.processErrorType(KotlinTypeMapper.kt:109)
at org.jetbrains.kotlin.codegen.MemberCodegen.genSimpleMember(MemberCodegen.java:203)
at org.jetbrains.kotlin.codegen.PackagePartCodegen.generateBody(PackagePartCodegen.java:95)
at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:129)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateFile(PackageCodegenImpl.java:149)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:70)
....etc.
I don' remeber that using ".bind()" should be necessary, so what import for the monadic either-computation block shoul I be using here ?Krystian Rybarczyk
12/07/2020, 8:54 PM@optics
sealed class AbstractUser : User() {
abstract val infos: List<UserInfo>
//subclassing data classes here
}
At some point I need to modify the infos
list and I don’t know which subtype it is. I don’t suppose it’s possible to use a lens here, is it?Bijan Chokoufe
12/08/2020, 4:56 PMEither
(coming from Scala) and can't get traverse
and sequence
to work 😅 . I have all of this already in my build.gradle
implementation "io.arrow-kt:arrow-core:$arrow_version"
implementation "io.arrow-kt:arrow-syntax:$arrow_version"
implementation "io.arrow-kt:arrow-core-data:$arrow_version"
implementation "io.arrow-kt:arrow-fx-rx2:$arrow_version"
implementation "io.arrow-kt:arrow-fx-reactor:$arrow_version"
implementation "io.arrow-kt:arrow-mtl:$arrow_version"
but none of this works
import arrow.core.Either
import arrow.core.Option
import arrow.core.computations.either
import arrow.core.extensions.either.applicative.applicative
import arrow.core.extensions.list.traverse.sequence
import arrow.core.extensions.option.applicative.applicative
import arrow.core.some
val eitherList: Either<*, List<*>> = listOf(Either.right("Foo")).sequence(Either.applicative())
val optionList: Option<List<Int>> =
listOf(1.some(), 2.some(), 3.some())
.sequence(Option.applicative())
as
Type mismatch: inferred type is Kind<EitherPartialOf<Nothing> /* = Kind<ForEither, Nothing> */, Kind<ForListK, String>> but Either<*, List<*>> was expected
(I tried following this https://www.47deg.com/blog/traverse-typeclass-in-arrow/ and https://arrow-kt.io/docs/apidocs/arrow-core-data/arrow.typeclasses/-traverse/)
I am on arrow_version = '0.11.0'
. Also is there a stable RC
of v1
? (I need reliable builds) Or how big of breaking changes can I expect? Is there a document on this somewhere?simon.vergauwen
12/10/2020, 12:47 PMRachel
12/11/2020, 8:59 AM0.12.0-SNAPSHOT
is ready!
1.0.0-SNAPSHOT
will be deleted within 1 hour.
Sorry for the inconveniences 🙏
See you!than_
12/11/2020, 10:03 AMA PR was raised to make Arrow Fx Coroutines depend on KotlinX Coroutines to easy integration and usage since almost everyone has KotlinX Coroutines on the classpath anyway. More details in the PR Reviews and feedback welcome: https://github.com/arrow-kt/arrow-fx/pull/317I noticed a little discrepancy in deprecation of
ForkConnected
here it should be ReplaceWith("async(ctx) { f() }", "kotlinx.coroutines.Deferred")
The thing is, signature of async
is CoroutineScope.async(ctx...
. But ForkConnected
itself doesn't need CoroutineScope
. Was this intended, or is it an oversight?Youssef Shoaib [MOD]
12/12/2020, 1:16 PMSam Halliday
12/13/2020, 10:04 AMgradle jmh
with Java 14 in that dir gets me a
Caused by: javax.lang.model.type.UnknownTypeException: Unknown type: "none" at com.squareup.kotlinpoet.TypeName$Companion$get$1.visitNoType(TypeName.kt:187)
trying again with java 8, I get a compilation error :blob-shrug:tieskedh
12/15/2020, 7:50 PMJolan Rensen [JetBrains]
12/16/2020, 4:48 PMproperty(ctx, { ... }) { prop: KtProperty ->
// now where is this property used?
Transform.replace(
replacing = prop,
newDeclaration = ...
)
}
CLOVIS
12/17/2020, 5:10 PMfun parse(List<String>): SomeDomainObject
That consists of many, many, many calls to startsWith
and similar in an enormous when
.
The data I'm parsing was not designed to be parsed by a program, but to be read by humans, so there's no automated way (like Kotlinx.Serialization)... Is there anything in Arrow or any programming pattern that could help clean up this code so it's easier to maintain?Gopal S Akshintala
12/18/2020, 10:27 AMValidatedPartialOf
is deprecated, coz Kind
is going away. Can someone please let me know how the below example will this be implemented in future. Thanks.
https://arrow-kt.io/docs/next/patterns/error_handling/#example--alternative-validation-strategies-using-applicativeerrorAlex Johnson
12/18/2020, 7:41 PMsuspend fun validateAndSave(a: RequestA): Either<Error, ModelA> = either {
val validA = validate(a).bind()
save(validA).bind()
}
would this be translated to the following and is that the expected route to take or is there some other syntacical sugar I can take advantage of?
suspend fun validateAndSave(a: RequestA): Either<Error, ModelA> = either {
val validA = validate(a)()
save(validA)()
}
Jörg Winter
12/18/2020, 10:19 PMval result = either<Throwable, Int> {
val allEmployees: List<Employee> = allEmployees()()
val greetings: List<EmailMessage> = birthdayMessages(allEmployees, date)()
val results: List<String> = greetings.parTraverseEither(<http://Dispatchers.IO|Dispatchers.IO>) {
println("before")
val greeting = sendGreeting(it)
println("after")
greeting
}()
results.map { println(it); 1 }.sum()
}
has no output before or afterGopal S Akshintala
12/19/2020, 6:55 AMsequence
. Is there a way to avoid 2 boilerplate `fix()`s in the below example to get that data type? Is there any on-going development on this, now that Kind
is being deprecated?
val listOfOptionalNumbers: List<Either<Int, Int>> =
listOf(1.right(), 2.right(),3.right())
val result: Either<Int, List<Int>> =
listOfOptionalNumbers.sequence(Either.applicative()).map { it.fix() }.fix()
Jörg Winter
12/21/2020, 1:29 PMPhani Mahesh
12/21/2020, 4:08 PMPhani Mahesh
12/21/2020, 4:08 PMpakoito
12/21/2020, 9:35 PMPhani Mahesh
12/22/2020, 11:21 AM