This file contains hidden or 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
interface Traced<E, S : Trace.Stage> { | |
val trace: Trace<E, S> | |
} | |
data class EffectTracer<E : Traced<E, Trace.Stage.Out>, M : Traced<E, Trace.Stage.In>> internal constructor( | |
private val state: State, | |
private val factory: (Trace<E, Trace.Stage.Out>) -> E | |
) { | |
fun launch(): Pair<EffectTracer<E, M>, Set<E>> { |
This file contains hidden or 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
sealed class HList { | |
object HNil : HList() | |
data class HNode<V, T : HList>(val value: V, val next: T) : HList() | |
data class HPlus<H1 : HList, H2 : HList>(val h1: H1, val h2: H2) : HList() // note this! | |
} |
This file contains hidden or 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
fun main() { | |
mock<WriteRound<Int, WriteRound<String, WriteRound<Boolean, Terminate>>>>() | |
.set(3) | |
.set("sss") | |
.set(true) | |
} | |
fun <T> mock(): T = TODO() |
This file contains hidden or 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
val src: List<Single<Unit>> = ... | |
fun sink(result: Single<Unit>) { ... } | |
src.map { it.toObservable().k() } | |
.sequence(ObservableK.applicative()).fix() | |
.map { Unit } | |
.observable | |
.firstElement() | |
.also(::sink) |
This file contains hidden or 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
fun main() { | |
val result = Free.fx<ForStore, String> { | |
put("arrow", "huita").bind() | |
update<String>("arrow") { "let's me do this" }.bind() | |
val arrow = get<String>("arrow").bind() | |
put("arrow-huita", "I have spoken").bind() | |
delete("arrow-huita") | |
arrow ?: "" | |
} |
This file contains hidden or 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
sealed class HList<T> | |
object HNil : HList<Nothing>() | |
data class HNode<T, H : HList<*>>( | |
val value: T, | |
val next: H | |
) : HList<H>() | |
infix fun <A, B> A.hcons(b: B): HNode<B, HNode<A, HNil>> = |
This file contains hidden or 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
class Lateinit<T> { | |
private var value: T? = null | |
private var dependants = mutableListOf<Dependant<T, *>>() | |
operator fun getValue(thisRef: Any?, kprop: KProperty<*>): T = | |
value ?: throw Exception() | |
operator fun setValue(thisRef: Any?, kprop: KProperty<*>, v: T) { | |
value = v |
This file contains hidden or 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
{-# LANGUAGE GADTs #-} | |
module Main where | |
newtype Login = Login String | |
newtype Password = Password String | |
data LoginState = Auth { | |
login :: Login, | |
password :: Password | |
} | Nop |
This file contains hidden or 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
sealed class Either2<A, B> { | |
data class Op1<A>(val value: A) : Either2<A, Nothing>() | |
data class Op2<B>(val value: B) : Either2<Nothing, B>() | |
} | |
sealed class Either3<A, B, C> : Either2<A, B>() { | |
This file contains hidden or 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
data class ChatState( | |
val messages: List<Message> = emptyList(), | |
val input: String = "" | |
) | |
sealed class ChatMutation { | |
data class NewMessage(val message: Message) : ChatMutation() | |
data class NewInput(val input: String) : ChatMutation() | |
object SendMessage : ChatMutation() | |
} |
NewerOlder