Skip to content

Instantly share code, notes, and snippets.

@kkismd
Created June 6, 2018 01:22
Show Gist options
  • Save kkismd/758c7d112f359157700c1fba3e8aa928 to your computer and use it in GitHub Desktop.
Save kkismd/758c7d112f359157700c1fba3e8aa928 to your computer and use it in GitHub Desktop.
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'arrowkt'
version '1.0-SNAPSHOT'
apply plugin: 'kotlin'
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'io.arrow-kt:arrow-core:0.7.1'
compile 'io.arrow-kt:arrow-syntax:0.7.1'
compile 'io.arrow-kt:arrow-typeclasses:0.7.1'
compile 'io.arrow-kt:arrow-data:0.7.1'
compile 'io.arrow-kt:arrow-instances-core:0.7.1'
compile 'io.arrow-kt:arrow-instances-data:0.7.1'
kapt 'io.arrow-kt:arrow-annotations-processor:0.7.1'
compile 'io.arrow-kt:arrow-free:0.7.1' //optional
compile 'io.arrow-kt:arrow-mtl:0.7.1' //optional
compile 'io.arrow-kt:arrow-effects:0.7.1' //optional
compile 'io.arrow-kt:arrow-effects-rx2:0.7.1' //optional
compile 'io.arrow-kt:arrow-effects-kotlinx-coroutines:0.7.1' //optional
compile 'io.arrow-kt:arrow-optics:0.7.1' //optional
compile 'io.arrow-kt:arrow-generic:0.7.1' //optional
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
apply plugin: 'kotlin-kapt' //optional
apply from: rootProject.file('gradle/generated-kotlin-sources.gradle') //optional
apply plugin: 'application'
mainClassName = 'hello.HelloKt'
package hello
import arrow.core.*
import arrow.typeclasses.*
import arrow.instances.*
import java.util.Collections.list
fun main(args: Array<String>) {
val a = ForOption extensions {
binding {
val a = 123.some().bind()
val b = 456.some().bind()
a + b
}.fix()
}
println(a) // => Some(579)
}
% ./gradlew build
w: /Users/shimada/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.31/...snip.../kotlin-stdlib-jre7-1.2.31.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
w: /Users/shimada/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.31/...snip.../kotlin-stdlib-jre7-1.2.31.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
w: /Users/shimada/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.31/...snip.../kotlin-stdlib-jre7-1.2.31.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
e: /Users/shimada/src/Kotlin/arrowkt/src/main/kotlin/hello/Hello.kt: (9, 13): Classifier 'ForOption' does not have a companion object, and thus must be initialized here
e: /Users/shimada/src/Kotlin/arrowkt/src/main/kotlin/hello/Hello.kt: (10, 9): Unresolved reference: binding
e: /Users/shimada/src/Kotlin/arrowkt/src/main/kotlin/hello/Hello.kt: (11, 32): Unresolved reference: bind
e: /Users/shimada/src/Kotlin/arrowkt/src/main/kotlin/hello/Hello.kt: (12, 32): Unresolved reference: bind
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
3 actionable tasks: 3 executed
@kkismd
Copy link
Author

kkismd commented Jun 6, 2018

https://twitter.com/pacoworks/status/1004174522365431808

Before 0.7.2 you need to do Option.monad().binding { } instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment