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
let forceFormat<'a>(a:'a) = match box a with | |
| :? Format as f -> f | |
| bad -> failwith ("not a format: " + bad.ToString()) | |
type P2<'a, 'b>(a:'a, b:'b) = | |
interface Format with member f.Translate l = | |
l.TypeApplication("P2", [forceFormat(a).Translate l; forceFormat(b).Translate l]) |
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
def map[A,B](fa: F[A])(f: A => B): F[B] = bind(fa)(a => unit(f(a))) | |
def join[A](f: F[F[A]]): F[A] = bind(f)(identity) | |
def kleisli[A,B](f: A => B): A => F[B] = a => unit(f(a)) | |
def bind2[A,B](fa: F[A])(f: A => F[B]): F[B] = join(map(fa)(f)) | |
def ap[A,B](f: F[A => B])(fa: F[A]): F[B] = bind(f)(fab => map(fa)(fab)) | |
def map2[A,B,C](fa: F[A], fb: F[B])(f: (A,B) => C): F[C] = bind(fa)(a => map(fb)(b => f(a,b))) | |
def map3[A,B,C,D](fa: F[A], fb: F[B], fc: F[C])(f: (A,B,C) => D): F[D] = | |
bind(fa)(a => bind(fb)(b => map(fc)(c => f(a,b,c)))) | |
def lift2[A,B,C](f: (A,B) => C): (F[A],F[B]) => F[C] = (fa,fb) => map2(fa,fb)(f) |
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
package jcdc.pluginfactory | |
object Queues{ | |
def main(args:Array[String]){ | |
println("queues with traits: lock then log") | |
QueuesWithTraitLinearization.lockThenLogQ.push(7) | |
println(QueuesWithTraitLinearization.lockThenLogQ.pop()) | |
println("\n") | |
println("queues with traits: log then lock") | |
QueuesWithTraitLinearization.logThenLockQ.push(7) |
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
def evalF(e:Exp): (Env[N,V] => V) = e match { | |
case ValE(v) => (_ => v) | |
case OpE(op, e1, e2) => e => op(evalF(e1)(e),evalF(e2)(e)) | |
case IdE(s) => e => e.find(s).getOrElse(sys.error("undefined variable: " + s)) | |
case LetE(IdE(s), e1, e2) => (e:Env[N,V]) => evalF(e2)(e.extend(s -> evalF(e1)(e))) | |
} | |
def eval(e:Exp)(implicit m: ReaderMonad[Env[N,V]]): Reader[Env[N,V],V] = e match { | |
case ValE(v) => m.unit(v) |
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
object HTMLWriterWebServer { | |
import unfiltered.request._ | |
import unfiltered.response._ | |
import unfiltered.netty._ | |
import unfiltered.netty.request._ | |
def main(a: Array[String]) { | |
case class Report(command:String, module:String) |
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
/** 22-way sum writer */ | |
def s22W[A0,F0,A1,F1,A2,F2,A3,F3,A4,F4,A5,F5,A6,F6,A7,F7,A8,F8,A9,F9,A10,F10,A11,F11,A12,F12,A13,F13,A14,F14,A15,F15,A16,F16,A17,F17,A18,F18,A19,F19,A20,F20,A21,F21,R](w0: Writer[A0,F0], w1: Writer[A1,F1], w2: Writer[A2,F2], w3: Writer[A3,F3], w4: Writer[A4,F4], w5: Writer[A5,F5], w6: Writer[A6,F6], w7: Writer[A7,F7], w8: Writer[A8,F8], w9: Writer[A9,F9], w10: Writer[A10,F10], w11: Writer[A11,F11], w12: Writer[A12,F12], w13: Writer[A13,F13], w14: Writer[A14,F14], w15: Writer[A15,F15], w16: Writer[A16,F16], w17: Writer[A17,F17], w18: Writer[A18,F18], w19: Writer[A19,F19], w20: Writer[A20,F20], w21: Writer[A21,F21]) | |
(f: (A0 => EffectW[S22[F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21]], A1 => EffectW[S22[F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21]], A2 => EffectW[S22[F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21]], A3 => EffectW[S22[F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11 |
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
Compiled from "Goo.scala" | |
public final class Goo extends java.lang.Object{ | |
public static int x(); | |
Code: | |
0: getstatic #16; //Field Goo$.MODULE$:LGoo$; | |
3: invokevirtual #18; //Method Goo$.x:()I | |
6: ireturn | |
} |
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
> update | |
[info] Updating {file:/Users/joshcough/work/MinecraftPlugins/core/}default-a38531... | |
[info] Resolving org.scala-lang#scala-library;2.10.0-M7 ... | |
[info] Resolving bukkit#craft-bukkit;1.3.1-R2.0 ... | |
[info] Resolving ch.spacebase#NPCCreatures;1.4 ... | |
[info] Resolving org.scalacheck#scalacheck_2.10;1.10.0 ... | |
[warn] module not found: org.scalacheck#scalacheck_2.10;1.10.0 | |
[warn] ==== local: tried | |
[warn] /Users/joshcough/.ivy2/local/org.scalacheck/scalacheck_2.10/1.10.0/ivys/ivy.xml | |
[warn] ==== sonatype-snapshots: tried |
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
val goto = Command("goto", "Teleport to a player.", args(player or (num ~ num ~ opt(num))){ | |
case you ~ Left(them) => you.teleportTo(them) | |
case you ~ Right(x ~ y ~ Some(z)) => you.teleport(you.world(x, y, z)) | |
case you ~ Right(x ~ z ~ None) => | |
you.teleportTo(you.world.getHighestBlockAt(you.world(x, 0, z))) | |
}) | |
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
name: MultiPlayerCommands | |
main: jcdc.pluginfactory.examples.MultiPlayerCommands | |
author: Josh Cough | |
version: 0.1 | |
database: false | |
commands: | |
goto: | |
description: Teleport to a player. | |
usage: /<command> (player-name or number number optional(number)) | |
set-time: |