Skip to content

Instantly share code, notes, and snippets.

Raúl Raja Martínez raulraja

View GitHub Profile
raulraja /
Last active Jul 8, 2022
Scala 3 Continuations

Pre-SIP: Suspended functions and continuations in Scala 3.

This Pre-SIP post proposes continuations as a new language feature in Scala 3.

It has been prepared by Jack Viers, Raul Raja and reviewed by the Scala 3 team at 47 Degrees. This doc is intended to be used as a way to gather community feedback and foster discussion.


Our observation in the industry and among our peers is that most programming in Scala today that involves async or I/O-based programs targets a monadic indirect boxed style.

View Issue2689.kt
package org.coral.fp.control
import arrow.core.ValidatedNel
import arrow.core.invalidNel
import arrow.core.validNel
import kotlin.jvm.JvmInline
public value class ProductId private constructor(public val value: Int) {
raulraja / pipe.kt
Created Mar 1, 2022
EffectScope pipe
View pipe.kt
package examples
import arrow.core.Either
import arrow.core.continuations.EffectScope
import arrow.core.continuations.either
object Request
object Response
sealed interface Error
object InvalidRequest : Error
raulraja / PartiallyAppliedFn.kt
Created Dec 22, 2021
Partially applied functions with selective arg application
View PartiallyAppliedFn.kt
package arrow.core
public fun interface Partial<A, B, C, D, Z> {
public operator fun invoke(a: A, b: B, c: C, d: D): Z
public fun first(a: A): Partial<Unit, B, C, D, Z> =
Partial { _, b, c, d -> invoke(a, b, c, d) }
public fun second(b: B): Partial<A, Unit, C, D, Z> =
Partial { a, _, c, d -> invoke(a, b, c, d) }
raulraja / Services.kt
Last active Dec 28, 2021
Services as composable suspended functions
View Services.kt
package arrow.meta.continuations
import arrow.core.Either
import arrow.core.computations.either
import arrow.core.flatMap
* Models errors as values
sealed interface Failure
View Derive.kt
package arrow.derive
* An Algebraic data type [Type] can derive behaviors
* for its members
sealed class Derive<in Type> {
* Derived instances associated to [Type]
raulraja /
Last active Jun 6, 2021
Given validation steps

Given validation steps

  1. Only top level class, object, property or function can be @Given declarations
@Given fun <T> et(@Given eq: Eq<T>): Eq<Tree<T>> = ...
  1. Declarations with Value parameters annotated as @Given for injection must
raulraja / adt_bound_constrain.kt
Created May 28, 2021
Constraint ADT for Flow Action and Reaction emit
View adt_bound_constrain.kt
/** Dummy login model **/
value class UserName(val value: String)
value class Password(val value: String)
* A [Reaction] is always parametric to a type of [Action]
View DBEffect.kt
package dbactions
import arrow.continuations.Effect
import arrow.continuations.generic.DelimitedScope
import kotlin.reflect.KClass
* An abstract connection
interface Connection {
raulraja / st.kt
Created Nov 14, 2020
Marco's question in slack
View st.kt
package arrow.prelude.test
import arrow.continuations.generic.DelimContScope
import arrow.continuations.generic.DelimitedScope
abstract class ST<S, A> @PublishedApi internal constructor() {
companion object {
operator fun <S, A> invoke(a: () -> A): ST<S, A> {
val memo by lazy(a)
return object : ST<S, A>() {