Skip to content

Instantly share code, notes, and snippets.

View BruceEckel's full-sized avatar
💭
Primarily working on Effect-Oriented Programming

Bruce Eckel BruceEckel

💭
Primarily working on Effect-Oriented Programming
View GitHub Profile
@jamesward
jamesward / kmonad.kts
Last active September 11, 2019 07:22
sealed class Bag<out THING> {
object Empty: Bag<Nothing>()
data class NonEmpty<out THING>(val thing: THING): Bag<THING>()
// Make a Bag with a THUNG in it
companion object {
fun <THUNG> make(thung: THUNG): Bag<THUNG> = NonEmpty(thung)
}
// Do stuff to the THING in the Bag by providing a thingToBagOfThang