一个用例示例:
def div2(i: Int): Validation[String, Int] =
if (i%2 == 0) Validation.success(i/2)
else Validation.failure("odd")
def div4(i: Int) = for {
a <- div2(i)
b <- div2(a)
} yield b
Run Code Online (Sandbox Code Playgroud)
错误:无法取消应用类型scalaz.Validation[String,Int]到M[_]由类型类别分类的类型构造函数scalaz.Bind
我猜错误是由编译器无法找到的Monad实例引起的Validation[String, Int]
我可以为自己制作一个,比如:
object Instances {
implicit def validationMonad[E] = new Monad[({type L[A] = Validation[E, A]})#L] {
override def point[A](a: => A) =
Validation.success(a)
override def bind[A, B](fa: Validation[E, A])(f: A => Validation[E, B]) =
fa bind f
} …Run Code Online (Sandbox Code Playgroud) 我已经阅读了 如何配置playframework服务器以支持ssl ,我也试图关注http://www.playframework.org/documentation/1.1.1/releasenotes-1.1#https但它对我不起作用
非常感谢〜
我阅读了Play1的文档,因为我无法找到有关https的Play2的更新信息.
在application.conf中,我添加了以下行:
https.port=9443
certificate.key.file=conf/host.key
certificate.file=conf/host.cert
Run Code Online (Sandbox Code Playgroud)
我键入run播放控制台,并尝试在https://localhost:9443浏览器超时时访问服务器,而无需在控制台输出中记录任何内容
考虑一个通用函数:
def genericFn[T](fn: T => Boolean): Unit = {
// do something involves T
}
Run Code Online (Sandbox Code Playgroud)
是否可以限制T(在编译时)一个简单的类型,而不是类似的类型List[Int]?
我想要解决的基础问题是这样的:
var actorReceive: Receive = PartialFunction.empty
def addCase[T](handler: T => Boolean): Unit = {
actorReceive = actorReceive orElse ({
case msg: T => // call handle at some point, plus some other logic
handler(msg)
})
}
Run Code Online (Sandbox Code Playgroud)
该addCase函数将导致类型擦除警告,这可以通过要求ClassTag如下来解决:def addCase[T: ClassTag](...,但ClassTag仍然无法防止如下调用:
addCase[List[Int]](_ => {println("Int"); true})
addCase[List[String]](_ => {println("String"); false})
actorReceive(List("str")) // will print "Int" …Run Code Online (Sandbox Code Playgroud) 如何从被隔离的系统中检测隔离状态〜?
我在下面看到这个日志:
[warn] Remoting - Tried to associate with unreachable remote address [akka.tcp://Application@192.168.0.15:6000]. Address is now gated for 5000 ms, all messages to this address will be delivered to dead letters. Reason: The remote system has quarantined this system. No further associations to the remote system are possible until this system is restarted.
但我不确定如何从代码中对此作出反应.
我找到了这个帖子:从Quarantined状态恢复,建议侦听QuarantinedEvent但是在被隔离的系统上没有调度.
我实际上听了所有RemotingLifecycleEvents并发现了这个:
AssociationError [akka.tcp://Application@192.168.0.100:2552] -> [akka.tcp://Application@192.168.0.15:6000]: Error [Invalid address: akka.tcp://Application@192.168.0.15:6000] [akka.remote.InvalidAssociation: Invalid address: akka.tcp://Application@192.168.0.15:6000
Caused by: akka.remote.transport.Transport$InvalidAssociationException: The …