-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeC implementation #1048
Merged
Merged
FreeC implementation #1048
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
01a3bb9
There was an attempt
nomisRev 7acb863
Emulated sealed interfaces
nomisRev 7802029
dirty version that compiles with multiple casts due to poor inference…
raulraja 222b0b2
Cleanup FreeC and complete port FS2
nomisRev f791700
Cleanup FreeC and complete port FS2
nomisRev 8624e2e
Fix infinite loop mk function and some tests
nomisRev f920695
Fix incorrect typeclass implementation
nomisRev de182e2
Add missing methods
nomisRev a1e49dc
Add documentation
nomisRev 3f869d5
infographic
nomisRev caafb2c
Fix detekt
nomisRev 37dc39a
Added bracketcase
nomisRev 1358942
Add FS2 LICENSE
nomisRev 545dca4
Clean up tests
nomisRev 3bdf812
Merge branch 'master' into fs2-port-poc
nomisRev bb2b4b2
Fix test
nomisRev 578f2ee
Fix visibility of public API
nomisRev a018b77
Clean up FreeC & make stack safe
nomisRev f82dac6
Merge branch 'master' into fs2-port-poc
nomisRev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
dependencies { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 it's alive! |
||
compile project(':arrow-effects') | ||
compile project(':arrow-instances-data') | ||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" | ||
testCompile "io.kotlintest:kotlintest:$kotlinTestVersion" | ||
testCompile project(':arrow-test') | ||
testCompile project(':arrow-effects-instances') | ||
|
||
compile project(':arrow-annotations') | ||
kapt project(':arrow-annotations-processor') | ||
kaptTest project(':arrow-annotations-processor') | ||
} | ||
|
||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle') | ||
apply plugin: 'kotlin-kapt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Maven publishing configuration | ||
POM_NAME=Arrow-Streams | ||
POM_ARTIFACT_ID=arrow-streams | ||
POM_PACKAGING=jar |
8 changes: 8 additions & 0 deletions
8
modules/streams/arrow-streams/src/main/kotlin/arrow/effects/ExitCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package arrow.effects | ||
|
||
//Temp copy until https://github.com/arrow-kt/arrow/pull/1043 is merged | ||
sealed class ExitCase<out E> { | ||
object Completed : ExitCase<Nothing>() | ||
object Cancelled : ExitCase<Nothing>() | ||
data class Error<out E>(val e: E) : ExitCase<E>() | ||
} |
44 changes: 44 additions & 0 deletions
44
modules/streams/arrow-streams/src/main/kotlin/arrow/streams/CompositeFailure.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package arrow.streams | ||
|
||
import arrow.core.* | ||
import arrow.data.Nel | ||
import arrow.data.NonEmptyList | ||
|
||
/** Represents multiple (>1) exceptions were thrown. */ | ||
data class CompositeFailure( | ||
val head: Throwable, | ||
val tail: Nel<Throwable> | ||
) : Throwable("Multiple exceptions were thrown (${1 + tail.size}), first $head: ${head.message}", head) { | ||
|
||
/** Gets all causes (guaranteed to have at least 2 elements). */ | ||
val all: NonEmptyList<Throwable> = Nel(head, tail.all) | ||
|
||
companion object { | ||
operator fun invoke(first: Throwable, second: Throwable, rest: List<Throwable> = emptyList()): CompositeFailure = | ||
CompositeFailure(first, Nel(second, rest)) | ||
|
||
fun fromList(error: List<Throwable>): Option<Throwable> = when { | ||
error.isEmpty() -> None | ||
error.size == 1 -> Some(error[0]) | ||
else -> Some(invoke(error[0], error[1], error.drop(2))) | ||
} | ||
|
||
/** | ||
* Builds composite failure from the results supplied. | ||
* | ||
* - When any of the results are on left, then the Left(err) is returned | ||
* - When both results fail, the Left(CompositeFailure(_)) is returned | ||
* - When both results succeeds then Right(()) is returned | ||
* | ||
*/ | ||
fun fromResults(first: Either<Throwable, Unit>, | ||
second: Either<Throwable, Unit>): Either<Throwable, Unit> = when (first) { | ||
is Either.Right -> second | ||
is Either.Left -> when (second) { | ||
is Either.Left -> Left(CompositeFailure(first.a, second.a, emptyList())) | ||
is Either.Right -> Left(first.a) | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one