gpt4 book ai didi

haskell 。 WAI 简单 Web 应用程序的问题(解包字节串)

转载 作者:行者123 更新时间:2023-12-04 06:13:49 28 4
gpt4 key购买 nike

对字符串和文本进行了大量打包、解包等操作,但仍然卡住,
目标很简单,就像 hello world 连接了额外的请求信息:

{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (statusOK)
import qualified Data.ByteString.Lazy as L
import Data.ByteString.Char8 (unpack)
import qualified Data.Text.Lazy as T

application req = do
return $ responseLBS statusOK [("Content-Type", "text/plain")]
$ L.pack $ "Hello World" ++ (unpack $ rawPathInfo req)

main = run 3000 application

产生:
Couldn't match expected type `GHC.Word.Word8'
against inferred type `Char'
Expected type: [GHC.Word.Word8]
Inferred type: [Char]
In the second argument of `(++)', namely
`(unpack $ rawPathInfo req)'
In the second argument of `($)', namely
`"Hello World" ++ (unpack $ rawPathInfo req)

迫切需要提示如何使其工作。

最佳答案

使用 Data.ByteString.Lazy.Char8.pack 而不是 L.pack。

关于 haskell 。 WAI 简单 Web 应用程序的问题(解包字节串),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7497881/

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