ScalaJPのWikiに置いて貰いました。 Scala開発環境構築手順
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
//funcLiteral ::= "{" [[ident {"," ident}] "=>"] lines "}" | |
def funcLiteral: Parser[AST] = "{"~>opt(repsep(ident, ",")<~"=>")~lines<~"}"^^{ | |
case Some(param)~x => Func(param.map(_.name), x) | |
case _~x => x | |
} |
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
scala> val s: Stream[Int] = Stream.continually {1} | |
s: Stream[Int] = Stream(1, ?) | |
scala> val i = s.grouped(3) | |
i: Iterator[scala.collection.immutable.Stream[Int]] = non-empty iterator | |
scala> i take 5 foreach println | |
Stream(1, ?) | |
Stream(1, ?) | |
Stream(1, ?) |
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[+A, M[A] <: Functor[A, M]] { | |
def map[B](f: A => B): M[B] | |
def fmap[B] = map[B] _ | |
} | |
trait Pointed[M[_] <: Pointed[M]] { | |
def pure[A](a: A): M[A] |
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 fuyuhatutometa; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.net.Socket; | |
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 ExSeq[+A] { | |
self: Seq[A] => | |
def mapBetween[B](f:(A,A)=>B): Iterator[B] = { | |
sliding(2).map(s=>f(s(0),s(1))) | |
} | |
} | |
object ExSeq { |
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
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLConnection; | |
public class PublicTimeLineViewer2 { | |
public static void main(String[] args) throws IOException { |
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
public abstract class Base { | |
public static class A extends Base { ... } | |
public static class B extends Base { ... } | |
public static Base createA(...) { return new A(...); } | |
public static Base createB(...) { return new B(...); } | |
public static interface Visitor<T> { | |
T visit(A a); | |
T visit(B b); |
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 Container[+R, +C] { | |
def map[A](f: C => A): Container[R, A] | |
def flatMap[RR >: R, A](f: C => Container[RR, A]): Container[RR, A] | |
def get[RR >: R](implicit ev: C <%< RR): RR | |
} | |
case class Calculating[+R, +C](element: C) extends Container[R, C] { |
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
[error] {file:/D:/home/nakamura/works/workspace/hogemage/}hogemage/compile:sources: java.lang.ExceptionInInitializerError | |
[error] application - | |
! Internal server error, for request [GET /] -> | |
play.api.UnexpectedException: Unexpected exception [ExceptionInInitializerError: null] | |
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$2$$anonfun$apply$11.apply(PlayReloader.scala:228) ~[na:na] | |
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$2$$anonfun$apply$11.apply(PlayReloader.scala:221) ~[na:na] | |
at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.2] | |
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$2.apply(PlayReloader.scala:221) ~[na:na] |