在简单的http GET示例上找不到模块`Network.HTTP&#39 [英] Could not find module `Network.HTTP' on simple http get example

查看:0
本文介绍了在简单的http GET示例上找不到模块`Network.HTTP&#39的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这个简单的例子:

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

我得到

/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
  | ^^^^^^^^^^^^^^^^^^^

我从这里尝试:Haskell: Could not find module ‘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

推荐答案

当您使用stack项目时,您应该首先在package.yamldependencies部分中add dependency这样:

dependencies:
- base >= 4.7 && < 5
- HTTP

然后运行stack build

这篇关于在简单的http GET示例上找不到模块`Network.HTTP&#39的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆