gpt4 book ai didi

haskell - 如何将 Data.Default 与 Network.HTTP.Client 结合使用

转载 作者:行者123 更新时间:2023-12-02 10:18:35 25 4
gpt4 key购买 nike

aws 包使用默认请求的实例(在 Aws/Core.hs 中)。在构建包的过程中,编译器会提示如下相同的错误。

下面是一些简单的事情,但也以同样的方式失败:

{-# LANGUAGE OverloadedStrings #-}
import Data.Default (def)
import Network.HTTP.Client (host)

main :: IO ()
main = do
print $ def { host = "http://foobar.com" }

编译器提示:

No instance for (Data.Default.Default
http-client-0.3.8.2:Network.HTTP.Client.Types.Request)
arising from a use of `def'
Possible fix:
add an instance declaration for
(Data.Default.Default
http-client-0.3.8.2:Network.HTTP.Client.Types.Request)

但我可以看到该实例是在 http-client/Network/HTTP/Client/Request.hs 中定义的:

instance Default Request where
def = Request
{ host = "localhost"
, port = 80
, secure = False
...

这是来自“干净”的环境:

$ cd
$ rm -Rf .cabal .ghc
$ cabal install cabal cabal-install
$ cabal install http-client-0.3.8.2

如何将默认值与请求一起使用?或者更好的是我如何构建 aws 包?

编辑: ghc-pkg 的输出

$ ghc-pkg list 
/var/lib/ghc/package.conf.d
Cabal-1.16.0
GLURaw-1.3.0.0
GLUT-2.4.0.0
HTTP-4000.2.8
HUnit-1.2.5.2
MonadCatchIO-mtl-0.3.0.5
OpenGL-2.8.0.0
OpenGLRaw-1.3.0.0
QuickCheck-2.6
X11-1.6.1.1
X11-xft-0.3.1
array-0.4.0.1
async-2.0.1.4
attoparsec-0.10.4.0
base-4.6.0.1
bin-package-db-0.0.0.0
binary-0.5.1.1
bytestring-0.10.0.2
case-insensitive-1.1.0.2
cgi-3001.1.8.3
containers-0.5.0.0
data-default-0.5.1
deepseq-1.3.0.1
directory-1.2.0.1
dlist-0.5
extensible-exceptions-0.1.1.4
fgl-5.4.2.4
filepath-1.3.0.1
ghc-7.6.3
ghc-prim-0.3.0.0
hashable-1.2.1.0
haskell-src-1.0.1.5
haskell2010-1.1.1.0
haskell98-2.0.0.2
hoopl-3.9.0.0
hpc-0.6.0.0
html-1.0.1.2
integer-gmp-0.5.0.0
mtl-2.1.2
network-2.4.1.2
old-locale-1.0.0.5
old-time-1.1.0.1
parallel-3.2.0.3
parsec-3.1.3
pretty-1.1.1.0
primitive-0.5.0.1
process-1.1.0.2
random-1.0.1.1
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.2
rts-1.0
split-0.2.2
stm-2.4.2
syb-0.4.0
template-haskell-2.8.0.0
text-0.11.3.1
time-1.4.0.1
transformers-0.3.0.0
unix-2.6.0.1
unordered-containers-0.2.3.0
utf8-string-0.3.7
vector-0.10.0.1
xhtml-3000.2.1
xmonad-0.11
xmonad-contrib-0.11.2
zlib-0.5.4.1
/home/ben/.ghc/i386-linux-7.6.3/package.conf.d
Cabal-1.20.0.2
asn1-encoding-0.8.1.3
asn1-parse-0.8.1
asn1-types-0.2.3
base64-bytestring-1.0.0.1
blaze-builder-0.3.3.4
byteable-0.1.1
cereal-0.4.0.1
cipher-aes-0.2.8
cipher-des-0.0.6
cipher-rc4-0.1.4
conduit-1.2.0.2
connection-0.2.3
cookie-0.4.1.3
cprng-aes-0.5.2
crypto-cipher-types-0.0.9
crypto-numbers-0.2.3
crypto-pubkey-0.2.4
crypto-pubkey-types-0.4.2.2
crypto-random-0.0.8
cryptohash-0.11.6
data-default-class-0.0.1
exceptions-0.6.1
http-client-0.4.0
http-client-tls-0.2.2
http-conduit-2.1.4.3
http-types-0.8.5
lifted-base-0.2.3.0
mime-types-0.1.0.4
mmorph-1.0.4
monad-control-0.3.3.0
nats-0.2
pem-0.2.2
publicsuffixlist-0.1
resourcet-1.1.2.3
securemem-0.1.3
semigroups-0.15.3
socks-0.5.4
streaming-commons-0.1.5
tls-1.2.9
transformers-base-0.4.3
void-0.6.1
x509-1.4.12
x509-store-1.4.4
x509-system-1.4.5
x509-validation-1.5.0

最佳答案

我猜您安装了两个不同版本的 data-defaultdata-default-classRequest 是其中一个类的实例,但不是另一个类的实例。不幸的是这是一个很常见的问题,你可以看到a similar answer I provided on Reddit .

关于haskell - 如何将 Data.Default 与 Network.HTTP.Client 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25970139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com