Skip to content

Instantly share code, notes, and snippets.

Raúl Raja Martínez raulraja

Block or report user

Report or block raulraja

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
View DefaultDicitionary.kt
package dictionary
/**
* A default dictionary is a map that provides a default concrete Monoid empty value for [B]
* Inspired by some of the examples of https://kotlinexpertise.com/default-map-in-kotlin/
* https://twitter.com/raulraja/status/1141697899383992325
*/
data class DefaultDictionary<A, B>(val empty: B, val underlying: Map<A, B> = emptyMap()) : Map<A, B> by underlying {
/**
@raulraja
raulraja / di.kt
Last active Jul 20, 2019
Simple Kotlin DI
View di.kt
package com.fortyseven.fptraining
import arrow.core.Either
import arrow.core.right
import arrow.effects.IO
import arrow.effects.extensions.io.fx.fx
data class Account(val balance: Int)
data class AccountEntity(val balance: Int)
@raulraja
raulraja / Capabilities.kt
Last active Feb 26, 2019
Kotlin transformers encoding for `Death of Final Tagless` by John De Goes.
View Capabilities.kt
package arrow.effects.zio.example
/** Capabilities aggregation ala Kotlin **/
class Capabilities(
console: Console,
random: Random
) : Console by console, Random by random
@raulraja
raulraja / ArrowTrial.kt
Last active Jan 6, 2019 — forked from bjonnh/ArrowTrial.kt
How to run suspend function in Arrow IOs
View ArrowTrial.kt
import arrow.core.left
import arrow.core.right
import arrow.effects.IO
import arrow.effects.extensions.io.applicativeError.handleErrorWith
import arrow.effects.extensions.io.monad.binding
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import java.time.LocalDateTime
@raulraja
raulraja / refinement.kt
Last active Nov 9, 2018
Type Refinement with Type Classes and ApplicativeError
View refinement.kt
package arrow.refined
import arrow.Kind
import arrow.core.*
import arrow.data.*
import arrow.effects.validated.positiveInt.plus
import arrow.effects.validated.positiveInt.positive
import arrow.extension
import arrow.instances.either.applicativeError.applicativeError
import arrow.instances.listk.traverse.traverse
@raulraja
raulraja / typeclassless_tagless_extensions.kt
Last active Jun 17, 2018
Tagless with Arrow & typeclassless using extension functions and instances
View typeclassless_tagless_extensions.kt
import arrow.Kind
import arrow.core.Option
import arrow.core.Try
import arrow.core.functor
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.functor
import arrow.typeclasses.Functor
/* algebras */
@raulraja
raulraja / dstagless.kt
Last active Dec 15, 2018
Tagless data source strategies with Arrow
View dstagless.kt
import arrow.Kind
import arrow.core.Option
import arrow.core.left
import arrow.core.right
import arrow.effects.typeclasses.Async
import arrow.typeclasses.ApplicativeError
data class UserId(val value: String)
data class User(val userId: UserId)
data class Task(val value: String)
@raulraja
raulraja / validation.kt
Last active May 9, 2019
Validation: Accumulating errors and failing fast in Arrow with `ApplicativeError`
View validation.kt
import arrow.*
import arrow.core.*
import arrow.typeclasses.*
import arrow.data.*
sealed class ValidationError(val msg: String)
data class DoesNotContain(val value: String) : ValidationError("Did not contain $value")
data class MaxLength(val value: Int) : ValidationError("Exceeded length of $value")
data class NotAnEmail(val reasons: Nel<ValidationError>) : ValidationError("Not a valid email")
@raulraja
raulraja / Tagless.kt
Last active Aug 27, 2018
Tagless in Kotlin with Arrow and manual DI
View Tagless.kt
import arrow.Kind
import arrow.core.Option
import arrow.core.Try
import arrow.core.functor
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.functor
import arrow.typeclasses.Functor
/* algebras */
@raulraja
raulraja / gist:9267f5c98c92eafe5b2abbf1d22027d8
Created Sep 30, 2016
Scala Exercises - LambdaWorld Scala Center Hackathon
View gist:9267f5c98c92eafe5b2abbf1d22027d8
https://github.com/scala-exercises/exercises-circe/issues/1
https://github.com/scala-exercises/exercises-stdlib/issues/4
https://github.com/scala-exercises/exercises-scalacheck/issues/16
https://github.com/scala-exercises/exercises-scalacheck/issues/8
https://github.com/scala-exercises/exercises-circe/issues/5
https://github.com/scala-exercises/exercises-circe/issues/4
https://github.com/scala-exercises/exercises-circe/issues/1
https://github.com/scala-exercises/scala-exercises/issues/452
You can’t perform that action at this time.