Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 找不到模块`Network.HTTP';关于简单的HTTPGET示例_Haskell_Ghc_Cabal - Fatal编程技术网

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`@Carsten
sh-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