Skip to content

Instantly share code, notes, and snippets.

Juan Ignacio Vimberg jivimberg

Block or report user

Report or block jivimberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dam5s
dam5s / Result.kt
Last active Jul 13, 2019
Railway oriented programming in Kotlin
View Result.kt
sealed class Result<A, B> {
abstract fun <C> map(mapping: (A) -> C): Result<C, B>
abstract fun <C> flatMap(mapping: (A) -> Result<C, B>): Result<C, B>
abstract fun <C> mapFailure(mapping: (B) -> C): Result<A, C>
abstract fun <C> flatMapFailure(mapping: (B) -> Result<A, C>): Result<A, C>
abstract fun orElse(other: A): A
abstract fun orElse(function: (B) -> A): A
}
data class Success<A, B>(val value: A) : Result<A, B>() {
@cretz
cretz / kotlin-annoyances.md
Last active Jul 30, 2019
Kotlin Annoyances
View kotlin-annoyances.md

Kotlin Annoyances

These are things that I found annoying writing a complex library in Kotlin. While I am also a Scala developer, these should not necessarily be juxtaposed w/ Scala (even if I reference Scala) as some of my annoyances are with features that Scala doesn't even have. This is also not trying to be opinionated on whether Kotlin is good/bad (for the record, I think it's good). I have numbered them for easy reference. I can give examples for anything I am talking about below upon request. I'm sure there are good reasons for all of them.

  1. Arrays in data classes break equals/hashCode and ask you to overload it. If you are going to need to overload it and arrays have no overridability, why not make the least-often use case (the identity-comparison equals) the exception?
@matklad
matklad / takeWhileInclusive.kt
Created Dec 24, 2016
An "inclusive" version of Kotlin's takeWhile
View takeWhileInclusive.kt
fun <T> Sequence<T>.takeWhileInclusive(pred: (T) -> Boolean): Sequence<T> {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = pred(it)
result
}
}
@gabrielemariotti
gabrielemariotti / README.md
Last active Aug 26, 2019
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)
View README.md

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

root
  --gradleScript
  ----dependencies.gradle
@staltz
staltz / introrx.md
Last active Sep 20, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
You can’t perform that action at this time.