また、Javaでは==や!=で比較できるのは基本型に限られ、オブジェクトの比較は原則としてequalsメソッドを使いました。Scalaでもこれはほぼ同じですが、テキスト(String)も==や!=で比較することができます。
String
だけ特別な扱いのような誤解をあたえる?
(:typelogic.core/var unquote _0) | |
(:typelogic.core/var unquote-splicing _0) | |
(:typelogic.core/var *print-length* nil) | |
(:typelogic.core/var list clojure.lang.IFn) | |
((:typelogic.core/var method-sig (:typelogic.core/fn ((_0) _1))) | |
:- | |
(_0 <:< java.lang.reflect.Method) | |
(clojure.lang.PersistentVector <:< _1)) | |
((:typelogic.core/var cons (:typelogic.core/fn ((_0 _1) _2))) | |
:- |
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.3" |
スタートアップ企業 Silk が、Haskellを採用した理由。
http://engineering.silk.co/post/31920990633/why-we-use-haskell
As a newly started company, we have a lot of technical decisions to make. One of the important ones is the choice of a programming language. Since we’re building a web application, this goes for both the client (i.e. the web browser) and the server.
新しく始めた会社として、我々はたくさんの技術的決定を行わなければなりません。中でも重要なのは、プログラミング言語の選択です。我々はウェブアプリケーションを作っていたので、この選択がクライアント(Webブラウザなど)とサーバの両方で必要になります。
On the client, there wasn’t much discussion. Javascript is the only viable choice, unless you want to use Flash or similar plugin-based models. But on the server, we had more freedom. Popular choices for web applications are dynamically typed languages like Ruby, Python and PHP, and statically typed languages like Java and C#.
import java.util.function.Function; | |
import java.util.*; | |
public class DB { | |
static void println(String s) { System.out.println(s); } | |
// java.sql.Connection | |
static class Connection implements AutoCloseable { | |
@Override public void close() { println("closed"); } | |
} |
Controller
のメソッド引数に Optional<ID<User>>
のような Generic な独自型を指定したい。
Validation
と連携したい。-parameters
を使用して、
Controller
メソッドの引数名からRequest Parameter名やPathParameter名を解決したい。
package controllers.util | |
import play.api.mvc.{Result, Controller} | |
import play.api.data.Form | |
import scala.util.Either.RightProjection | |
object Implicits { | |
implicit def formToEither[A](form: Form[A]): Either[Form[A], A] = form.fold(Left.apply, Right.apply) |
[2014-09-06 08:09:28 JST] (INFO) start | |
[2014-09-06 08:09:39 JST] (INFO) irc|taisukeoe|hello | |
[2014-09-06 08:09:38 JST] (INFO) twitter|niw|Okay, my presentation is not ready (ouch!) yet heading to Shibuya soon. #ScalaMatsuri | |
[2014-09-06 08:09:38 JST] (INFO) twitter|makoto78sasaki|#ScalaMatsuri へ出発 | |
[2014-09-06 08:09:39 JST] (INFO) twitter|s_kozake|さて、向かうで! | |
#ScalaMatsuri | |
[2014-09-06 08:09:41 JST] (INFO) twitter|cbirchall|寝坊!今日に限って目覚ましが鳴らないとは。今向かっています #ScalaMatsuri | |
[2014-09-06 09:09:41 JST] (INFO) twitter|sm0kym0nkey|到着 #ScalaMatsuri | |
[2014-09-06 09:09:41 JST] (INFO) twitter|jagd5168|なんとか目を覚まし 9:45 到着予定 #ScalaMatsuri | |
[2014-09-06 09:09:41 JST] (INFO) twitter|iyunoriue|#ScalaMatsuri 今日ボランティアやってますv(*・∀・*)ピース |