Skip to content

Instantly share code, notes, and snippets.

View hiroshi-cl's full-sized avatar

Hiroshi YAMAGUCHI hiroshi-cl

  • Some company
  • Tokyo, Japan
View GitHub Profile
(* A tagless-final embedding of the language with shift/reset
operators and fully supported answer-type modification (ATM).
This implementation is based on the prompt-passing translation
described in the paper "ATM without tears: prompt-passing style
transformation for typed delimited-control operators"
http://ebooks.au.dk/index.php/aul/catalog/view/4/4/31-1
*)
open Delimcc;;
@phenan
phenan / Parsers.scala
Created May 23, 2017 03:30
Parser combinators implemented in tagless-final style
import scala.language.higherKinds
import scalaz._
import scalaz.std.option._
import scalaz.syntax.monadPlus._
trait Parsers [Elem, C[+_], Repr[+_, _, _[_]]] {
def cond (f: Elem => Boolean): Repr[Elem, Elem, C]
def elem (e: Elem): Repr[Elem, Elem, C] = cond(_ == e)
def success [T] (r: T): Repr[T, Elem, C]
def failure (msg: String): Repr[Nothing, Elem, C]