sitepodmatt
03/06/2019, 1:28 PMsitepodmatt
03/06/2019, 1:28 PMpakoito
03/06/2019, 2:02 PMpakoito
03/06/2019, 2:02 PMpakoito
03/06/2019, 2:02 PMBob Glamm
03/06/2019, 2:07 PMraulraja
03/06/2019, 2:27 PMimport arrow.core.Some
import arrow.core.None
val remoteInput = Some("blue")
.flatMap { if(it.isNullOrBlank()) None else Some(it.trim()) }
.map { it.toLowerCase() }
val vi = remoteInput.toEither { Exception("No valid input") }
fun main(args: Array<String>) {
println(remoteInput)
println(vi)
}
This is most likely a JDK bug or Kotlin compiler bug in codegen. Do you have a full example including imports?sitepodmatt
03/06/2019, 2:36 PMsitepodmatt
03/06/2019, 2:36 PMpackage personal
import arrow.core.None
import arrow.core.Some
fun main() {
val remoteInput = Some("blue")
.flatMap { if(it.isNullOrBlank()) None else Some(it.trim()) }
.map { it.toLowerCase() }
println(remoteInput)
val vn = remoteInput.toEither { Exception("No valid input") }
println(vn)
}
sitepodmatt
03/06/2019, 2:37 PMsitepodmatt
03/06/2019, 2:38 PMBob Glamm
03/06/2019, 2:42 PMsitepodmatt
03/06/2019, 2:53 PMsitepodmatt
03/06/2019, 3:03 PMsitepodmatt
03/06/2019, 3:11 PMsitepodmatt
03/06/2019, 3:52 PMval remoteInput = Option.fromNullable(getRemoteInput())
val output = remoteInput
.toEither { Exception("No input") }
.flatMap { input ->
if(input.isNullOrBlank()) Exception("Blank input").left() else input.trim().right()
}
.handleErrorWith {
// do some logging
Option.fromNullable(getAlternativeRemoteInput()).toEither { Exception("No input")}... and so on
}
sitepodmatt
03/06/2019, 3:52 PMpakoito
03/06/2019, 4:01 PMpakoito
03/06/2019, 4:01 PMpakoito
03/06/2019, 4:01 PMsitepodmatt
03/06/2019, 4:08 PMpakoito
03/06/2019, 4:11 PMFunctor.map
or Applicative.map
sitepodmatt
03/06/2019, 4:12 PMpakoito
03/06/2019, 4:12 PMmyEither.map { bla }
, map(oneEither, otherEither) { one, two -> bla(one + two) }
pakoito
03/06/2019, 4:13 PMHexa
03/07/2019, 7:13 PM// event: List<KinesisEvent.KinesisEventRecord>
event.records.forEach {
try {
val putRecordsRequest = PutRecordsRequest()
putRecordsRequest.streamName = "test-stream"
val putRecordsRequestEntryList = ArrayList<PutRecordsRequestEntry>()
for (i in 0..499) {
val putRecordsRequestEntry = PutRecordsRequestEntry()
putRecordsRequestEntry.data = it.kinesis.data
putRecordsRequestEntry.partitionKey = it.kinesis.partitionKey
putRecordsRequestEntryList.add(putRecordsRequestEntry)
}
putRecordsRequest.setRecords(putRecordsRequestEntryList)
val putRecordsResult = kinesisClient.putRecords(putRecordsRequest)
} catch (e: InterruptedException) {
//log error here
}
Hexa
03/07/2019, 7:14 PMkinesisEvent.records.asSequence()
before calling foreach?pakoito
03/07/2019, 7:41 PMpakoito
03/07/2019, 7:41 PMpakoito
03/07/2019, 7:42 PM