Skip to content

Instantly share code, notes, and snippets.

View viktorklang's full-sized avatar

Viktor Klang (√) viktorklang

View GitHub Profile
abstract class some[X](val value : X) { type T = X }
abstract class someFactory[S <: some[_]](val P : (S#T) => boolean)
{
def apply(t : S#T) : Option[S] = if(P(t)) Some(fetch(t)) else None
def unapply(s : S) : Option[S#T] = if(s == null) None else Some(s.value)
def fetch(t : S#T) = mk(t)