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
trait Decorable[A, B] { | |
def decorate(obj: A, dec: B): Either[String, A] | |
} | |
object Decorator { | |
def decorate[A, B](implicit d: Decorable[A,B]) = d | |
} | |
object TagsDecorator { |
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
trait Functor { | |
type M <: { type T } | |
def fmap[A, B](fa: M { type T = A })(f: A => B): M { type T = B } | |
} | |
implicit class EitherRightFunctor extends Functor { self => | |
type L | |
type M = Either { type A = self.L ; type T = B } //doesn't this specify a subtype of Either, rather than Either itself? | |
def fmap[A0, B0](fa: M { type A = self.L ; type B = A0 })(f: A0 => B0): Either { type A = self.L ; type B = B0 } = |
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 ModelCombinator extends JavaTokenParsers { | |
def mod: Parser[Any] = "model" ~ ident ^^ { | |
case x => println("Hoping for string value of ident " + x.toString()) | |
} | |
def model: Parser[Any] = "model" ~ ident ~ "{" ~ rep(member) ~ "}" | |
def member: Parser[Any] = ident ~ ":" ~ ident ~ "@" ~ ("eager" | "lazy") ~ relation.? ~ ";" | |