Skip to content

Commit 4f93898

Browse files
committed
Arranged the sources into packages.
Added sourcesJar.
1 parent 8a04604 commit 4f93898

File tree

16 files changed

+34
-3
lines changed

16 files changed

+34
-3
lines changed

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
group 'com.github.h0tk3y.kotlinMonads'
2-
version '1.0-SNAPSHOT'
3-
41
buildscript {
52
ext.kotlin_version = '1.1-M03'
63

@@ -24,3 +21,8 @@ dependencies {
2421
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
2522
testCompile "junit:junit:4.12"
2623
}
24+
25+
task sourcesJar(type: Jar, dependsOn: classes) {
26+
classifier = 'sources'
27+
from sourceSets.main.allSource
28+
}

src/main/kotlin/DoNotation.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/DoNotation.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package com.github.h0tk3y.kotlinMonad
12

23
import java.io.Serializable
34
import java.util.*

src/main/kotlin/Either.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/Either.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
sealed class Either<F, out T> : Monad<Either<F, *>, T> {
24
class Left<F>(val leftValue: F) : Either<F, Nothing>()
35
class Right<T>(val rightValue: T) : Either<Nothing, T>()

src/main/kotlin/Maybe.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/Maybe.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
sealed class Maybe<out T> : Monad<Maybe<*>, T> {
24
data class Just<T>(val value: T) : Maybe<T>() {
35
override fun toString() = "Just $value"

src/main/kotlin/Monad.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/Monad.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
interface Return<M> {
24
fun <T> returns(t: T): Monad<M, T>
35
}

src/main/kotlin/MonadList.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/MonadList.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
data class MonadList<out T>(val list: List<T>) : Monad<MonadList<*>, T>, List<T> by list {
24
override fun <R> bind(f: Binder<MonadList<*>, T, R>): MonadList<R> =
35
MonadList(list.flatMap { f(MonadListReturn, it) as MonadList })

src/main/kotlin/Reader.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/Reader.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
class Reader<E, out T>(val runReader: (E) -> T) : Monad<Reader<E, *>, T> {
24
override fun <R> bind(f: Binder<Reader<E, *>, T, R>): Reader<E, R> = Reader { a ->
35
val t = runReader(a)

src/main/kotlin/State.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/State.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
class State<S, out T>(val runState: (S) -> Pair<S, T>) : Monad<State<S, *>, T> {
24
override fun <R> bind(f: Binder<State<S, *>, T, R>): State<S, R> = State { s ->
35
val (newState, value) = runState(s)

src/main/kotlin/Writer.kt renamed to src/main/kotlin/com/github/h0tk3y/kotlinMonad/Writer.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
data class Writer<T>(val result: T, val log: String) : Monad<Writer<*>, T> {
24
override fun <R> bind(f: Return<Writer<*>>.(T) -> Monad<Writer<*>, R>): Writer<R> {
35
val w = f(WriterReturn, result) as Writer

src/test/kotlin/DoNotationTest.kt renamed to src/test/kotlin/com/github/h0tk3y/kotlinMonad/DoNotationTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.github.h0tk3y.kotlinMonad
2+
13
import org.junit.Assert.assertEquals
24
import org.junit.Assert.assertFalse
35
import org.junit.Test

0 commit comments

Comments
 (0)