Created
August 21, 2014 20:12
-
-
Save djspiewak/98c64c2759b5475b8fa8 to your computer and use it in GitHub Desktop.
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
implicit object ParserApplicative extends Applicative[Parser] { | |
def point[A](a: A): Parser[A] = "" ^^^ a | |
def ap[A, B](left: => Parser[A])(right: => Parser[A => B]): Parser[B] = | |
left ~ right ^^ { (a, f) => f(a) } | |
} | |
implicit def parserSemigroup[A]: Semigroup[Parser[A]] = new Semigroup[Parser[A]] { | |
def append(left: Parser[A], right: => Parser[A]): Parser[A] = left | right | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment