所以我想尝试http客户端
package com.company;
import jdk.incubator.http.HttpClient;
public class Main {
public static void main(String[] args) {
HttpClient client = HttpClient.newHttpClient();
}
}
Run Code Online (Sandbox Code Playgroud)
我的模块信息看起来像这样
module com.company {
requires jdk.incubator.httpclient;
}
Run Code Online (Sandbox Code Playgroud)
但我明白了 java.lang.NoClassDefFoundError: jdk/incubator/http/HttpClient
我真的不明白为什么.我的java版本是"build 9-ea + 169",我使用最新版本的IntelliJ idea(2017.1.3).我查看了这个答案,看起来我只需要将需求添加到文件中,但由于某种原因它不起作用.
我是Haskell的新手并且创建了这个类
class Printable a where
toString :: a -> String
Run Code Online (Sandbox Code Playgroud)
还有两个例子
instance Printable Bool where
toString x | x == True = "true"
| x == False = "false"
instance Printable () where
toString x = "unit type"
Run Code Online (Sandbox Code Playgroud)
它们工作得很好,现在我想创建一个带有两个参数的实例,但是我遇到了麻烦.到目前为止我创造的是
instance (Printable a, Printable b) => Printable (a, b) where
toString x | fst x == True = "(true,unit type)"
Run Code Online (Sandbox Code Playgroud)
但现在我得到了错误
无法将预期类型'a'与实际类型'Bool'匹配
这是合理的,但是当我替换a为BoolI时也会出错.我怎样才能使它在首位的工作,我可以限制类型a和b-例如,如果我想要的东西a永远是Bool和b永远是()?