我是哈斯克尔的新手。在哈斯克尔做这样的事情会有什么好办法?
19:18:36,042 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."cargo-tracker.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."cargo-tracker.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "cargo-tracker.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found
at org.jboss.msc.service.ServiceContainerImpl.getRequiredService(ServiceContainerImpl.java:669)
at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.getDefaultResourceAdapterName(MessageDrivenComponentDescriptionFactory.java:274)
at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processMessageBeans(MessageDrivenComponentDescriptionFactory.java:154)
at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processAnnotations(MessageDrivenComponentDescriptionFactory.java:81)
at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:57)
at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
19:18:36,050 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "cargo-tracker.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"cargo-tracker.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"cargo-tracker.war\".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment \"cargo-tracker.war\"
Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"cargo-tracker.war\".PARSE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
19:18:36,080 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "cargo-tracker.war" (runtime-name : "cargo-tracker.war")
19:18:36,083 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."cargo-tracker.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."cargo-tracker.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "cargo-tracker.war"
答案 0 :(得分:6)
Haskell是功能和声明性语言。这意味着通常没有太多“做某事”。还有更多计算某些东西并将其返回。
这可能看起来像挑剔,但是例如在Haskell中,无法设置变量两次:一旦你为它分配一个表达式(本身不是一个值) ,您无法将其设置为不同的值。
如果您想要返回某些内容,通常会使用模式匹配。例如:
f :: Bool -> String
f True = "Yes"
f False = "No"
这在Java / C#/ ...中有点等同于:
public String f (boolean var1) {
if(var1) {
return "Yes";
} else {
return "No";
}
}
请注意,Haskell也可以 lazy :如果你返回一个函数调用或者任何东西,你不会立即评估该函数调用:只有那样才会评估一个调用是必要的。
如何进行I / O可能会出现问题。为此,有一个I / O monad的概念。 monad是一种函数式编程技术,可以执行某种评估顺序。
但是函数式编程因此需要与命令式编程不同的“思维模式”:你不会想到命令方面的程序一个接一个地完成,但更多的是在一起组合函数以生成给定输入的输出。像通常是数学家或物理学家一样。例如,你给出一个函数,给定物体的质量和速度,计算该物体的动能。
答案 1 :(得分:3)
Haskell有if-then-else条件。
我能写的最接近你的代码是这样的:
let var = length "hello" == 5
in if var then "ok" else "no"
请注意,这样的条件更类似于C或Java的var ? "ok" : "no"
表达式,而不是if()...
语句,但这是因为Haskell功能正常,所以它没有&# 34;陈述",只有表达。
任何Haskell教程都应该涵盖这一点。如果你想学习Haskell,我建议你读一个。试图从其他语言转换成语是一种糟糕的策略。