Skip to content

Instantly share code, notes, and snippets.

@travisbrown
Created October 17, 2011 21:53
Show Gist options
  • Save travisbrown/1293947 to your computer and use it in GitHub Desktop.
Save travisbrown/1293947 to your computer and use it in GitHub Desktop.
path-dependent-type-monad
object test {
trait M[X[_]] {
def map[A, B](a: X[A])(f: A => B): X[B]
}
trait Parsers {
trait Parser[Y] {
def map[B](f: Y => B): Parser[B] = null
}
}
def parserM[G <: Parsers with Singleton ]: M[({ type L[T] = G#Parser[T] })#L] =
new M[({ type L[T] = G#Parser[T] })#L] {
def map[A, B](a: G#Parser[A])(f: A => B): G#Parser[B] = a.map(f)
}
object a extends Parsers {
val x = parserM[a.type]
x: M[a.Parser]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment