case class Person(id: Long, name: String, organizationId: Long)
object Person {
def groupByOrg: Map[Long, Seq[Person]] = ...
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 doAction6 = Action { implicit req => | |
(for { | |
_ <- authorizeHeaders(req.headers) \/> BadRequest("Unauthorized request") | |
json <- req.body.asJson \/> BadRequest("Wrong POST body") | |
user <- validateJson(json) \/> BadRequest("Invalid JSON") | |
} yield { | |
doSomething(user) | |
Ok("Success") | |
}).merge | |
} |
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.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.Arrays; | |
import java.util.Map.Entry; | |
import java.util.Map; | |
import java.util.stream.Stream; | |
import static java.util.Comparator.comparing; | |
import static java.util.stream.Collectors.groupingBy; | |
import static java.util.stream.Collectors.counting; |
Haskellのforallについて理解したことを書いておく(ランクN多相限定)。 より拝借
-- コンパイル通らない
func:: ([a] -> Int) -> Int
func f = f [1, 2, 3] + f["a", "b", "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
scala> val f: (Option[Int], Int) => Option[Int] = _ orElse Some(_) | |
f: (Option[Int], Int) => Option[Int] = <function2> | |
scala> val seq: Seq[Int] = Seq(1,2,3) | |
seq: Seq[Int] = List(1, 2, 3) | |
scala> seq.foldLeft(Some(0))(f) | |
<console>:10: error: type mismatch; | |
found : (Option[Int], Int) => Option[Int] | |
required: (Some[Int], Int) => Some[Int] |
機能\サービス | Travis CI | Circle CI | Shippable | Wercker | BuildHive |
---|---|---|---|---|---|
Private Repo | 有料 | 無料 | 無料 | 無料 | |
/**
* {{{
* prop> import org.scalacheck.{Gen, Arbitrary}
* prop> import org.scalacheck.Arbitrary._
* prop> import foo.BarType
* prop> val itemTypeGen = Gen.oneOf(BarType.values)
* prop> implicit val barTypeArbitrary = Arbitrary(barTypeGen)
* prop> (i: Int, t: BarType) => i > 10
* }}}
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
[fooo] $ test | |
[info] Compiling 1 Scala source to C:\Users\ma-nakamura\workspace\fooo\target\scala-2.11\classes... | |
[trace] Stack trace suppressed: run last *:doctestGenTests for the full output. | |
[error] (*:doctestGenTests) java.nio.charset.MalformedInputException: Input length = 1 | |
[error] Total time: 5 s, completed 2014/12/18 14:06:38 | |
[fooo] $ test |