Skip to content

Instantly share code, notes, and snippets.

View arnolddevos's full-sized avatar

Arnold deVos arnolddevos

View GitHub Profile
@arnolddevos
arnolddevos / thing.scala
Last active August 29, 2015 14:06
some sort of monad defined in terms of a sort of fold
package thing
import scala.language.higherKinds
trait Thing[+T, Context[_]] { parent =>
def foldish[S](s0: S)(f: (S, T) => Context[S]): Context[S]
def map[U](g: T => U) = new Thing[U, Context] {
def foldish[S](s0: S)(f: (S, U) => Context[S]) =
parent.foldish(s0)((s, t) => f(s, g(t)))