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
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>() { |
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
/** Bifunctor IO */ | |
class IO<out E, out A> : | |
`*`<IO<*, *>>, | |
`*-*`<IO<*, *>, A>, | |
`*-*-*`<IO<*, *>, E, A> { | |
fun <B> fmap(f: (A) -> B): IO<Nothing, B> = TODO() | |
fun <B> flatMap(f: (A) -> `*-*`<IO<*, *>, B>): IO<Nothing, B> = TODO() | |
fun <C, D> bimap(fl: (E) -> C, fr: (A) -> D): IO<C, D> = TODO() | |
companion object { |
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
import arrow.fx.* | |
import arrow.fx.extensions.* | |
import arrow.fx.typeclasses.* | |
import arrow.fx.extensions.io.bracket.guaranteeCase | |
fun <A> IOOf<A>.onCancel(token: IOOf<Unit>): IO<A> = | |
guaranteeCase { case -> | |
when (case) { | |
ExitCase.Canceled -> token | |
else -> IO.unit |
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
package arrow.rules.test | |
import arrow.Kind | |
import arrow.core.Either | |
import arrow.core.EitherPartialOf | |
import arrow.core.Nel | |
import arrow.core.NonEmptyList | |
import arrow.core.Validated | |
import arrow.core.ValidatedPartialOf | |
import arrow.core.extensions.either.applicativeError.applicativeError |
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
/* Coming up ~ April 2020 */ | |
package test | |
import arrow.* | |
inline class TwitterHandle(val handle: String) { | |
companion object : Refined<String> { | |
override val validate: String.() -> Map<String, Boolean> = { | |
mapOf( | |
"Should start with '@'" to startsWith("@"), |
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
package arrow.meta.ide.plugins.proofs.contracts | |
import kotlin.contracts.Effect | |
import kotlin.contracts.ExperimentalContracts | |
interface TypeLevelEffect : Effect | |
interface Declaration : Effect | |
fun declaration(): Declaration = TODO() |
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
package arrow.meta.plugins.helloWorld | |
import arrow.meta.Meta | |
import arrow.meta.Plugin | |
import arrow.meta.invoke | |
import arrow.meta.phases.analysis.ElementScope | |
import arrow.meta.quotes.ClassScope | |
import arrow.meta.quotes.Scope | |
import arrow.meta.quotes.Transform | |
import arrow.meta.quotes.classOrObject |
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
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 { | |
/** |
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
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) |
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
package arrow.effects.zio.example | |
/** Capabilities aggregation ala Kotlin **/ | |
class Capabilities( | |
console: Console, | |
random: Random | |
) : Console by console, Random by random |