This file contains 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 Blocking extends Unwrapped[A], StarterLib: | |
val ec: ExecutionContextExecutorService = | |
ExecutionContext.fromExecutorService(Executors.newSingleThreadExecutor()) | |
sys.addShutdownHook(this.close) | |
def close: Unit = ec.close() | |
def apply(block: Continuation[A] ?=> A): A = | |
val boundary = new Boundary[A] { var result = null } | |
val latch = new CountDownLatch(1) | |
val baseContinuation = BuildContinuation( | |
ec, |
This file contains 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
abstract class Starter[A]: | |
def invoke(completion: Continuation[A]): A | Any | Null | |
trait ContinuationLib: | |
extension [A](continuation: Continuation[A]) | |
def intercepted(ec: ExecutionContext): Continuation[A] = | |
continuation match | |
case x: ContinuationImpl => | |
x.intercepted(ec).asInstanceOf[Continuation[A]] | |
case _ => continuation |
This file contains 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
def runNextLeg(a: Int, b: Int)(completion: Continuation[Int]): Int | Suspended = | |
var a$1:Int = a | |
var b$2:Int = b | |
var z$3:Boolean = null | |
var m$4:Int = null | |
var g$5:Int = null | |
val frame = frame match { | |
case x$0 @ _:GcdFrame if x$0.state & Int.MinValue != 0 => | |
x$0.state = x$0.state - Int.MinValue | |
x$0 |
This file contains 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
/** | |
* Code Snippets from the Blog Post "Basic Recursion Schemes in Scala", | |
* https://www.47deg.com/blog/basic-recursion-schemes-in-scala/ | |
* | |
* Written here to accompany the article. This file should compile directly if inserted into ammonte. | |
*/ | |
object IListBase { | |
sealed trait IList | |
case object INil extends IList | |
case class ICons(head: Int, tail: IList) extends IList |
This file contains 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
#!/usr/bin/bash | |
export OWNER=$1 | |
export REPOSITORY=$2 | |
export LOGIN="<GITHUB_LOGIN>" | |
export TOKEN="<GITHUB_TOKEN>" | |
processPullRequest() { | |
NUMPR=$1 | |
COMMIT=$2 |
This file contains 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
type Lazy[A] = () => A | |
def foldRight[A, B](xs: List[A], z: B)(f: (A, Lazy[B]) => B): B = | |
xs match { | |
case Nil => z | |
case h :: t => f(h, () => foldRight(t, z)(f)) | |
} | |
def find[A](xs: List[A])(p: A => Boolean): Option[A] = { | |
val init = Option.empty[A] |
This file contains 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
module OrderedFairChunks where | |
import Data.List | |
import Data.Maybe | |
import Data.Function(on) | |
-- Useful type aliases | |
type Cons a = (a, [a]) | |
type Slice k v = (k, [v]) |