Haskell 找不到模块`Network.HTTP';关于简单的HTTPGET示例
我正在尝试这个简单的例子:Haskell 找不到模块`Network.HTTP';关于简单的HTTPGET示例,haskell,ghc,cabal,Haskell,Ghc,Cabal,我正在尝试这个简单的例子: module Main where import Network.HTTP import Lib get :: String -> IO String get url = simpleHTTP (getRequest url) >>= getResponseBody -- 2. Get the response code getCode :: String -> IO ResponseCode getCode url = simpleHT
module Main where
import Network.HTTP
import Lib
get :: String -> IO String
get url = simpleHTTP (getRequest url) >>= getResponseBody
-- 2. Get the response code
getCode :: String -> IO ResponseCode
getCode url = simpleHTTP req >>= getResponseCode
where req = getRequest url
main :: IO ()
main = do
x <- get "http://google.com"
putStrLn x
我在这里试过:
当您使用
堆栈
项目时,您应该首先在包的依赖项
部分。yaml
如下所示:
依赖项:
-基数>=4.7&<5
-HTTP
然后运行
stack build
如何安装Haskell(GHC/Cabal)?您是如何设置/编译程序的?您使用的是哪个版本的cabal?@lsmor cabal`3.4.0.0`@Carstensh-c“curl--proto'=https'--tlsv1.2-sSfhttps://get-ghcup.haskell.org |sh“
和堆栈运行
我猜GHC不在您的路径中(阴谋集团没有找到它)-您编写了您使用的堆栈
-可能您使用了堆栈设置
?如果它不在您的路径中安装GHC,那么在这种情况下,您也应该使用stack
来安装依赖项
/workspaces/hask_exercises/api-exercises/app/Main.hs:2:1: error:
Could not find module `Network.HTTP'
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
2 | import Network.HTTP
| ^^^^^^^^^^^^^^^^^^^
cabal install --lib network
cabal: The program 'ghc' version >=7.0.1 is required but it could not be
found.
ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.4