Haskell-someImportantResource

Reading time: 2 minutes and 17 seconds with 505 words. 本文总阅读量
  • The most important is:Hackage-haskell-Official Maintains a central repository of open source Hakell libraries called Hackage.
cabal install HTTP

cabal四个阶段:

  • fetches 获取
  • configures 配置
  • compiles 编译
  • installs 安装

所以安装HTTP库(一般库也是一样)

  1. Refresh the list Download the recent list of packages
cabal update
  1. Install the package find any package from Hackage
cabal install HTTP
  1. Use Cabal takes care of installing the package. The library can now be imported
---new file.hs
import Network.HTTP
  1. 使用hackage.haskell.org/packages/HTTP查看HTTP的使用方式 可以查看这个网页下的 Modules Network 包含着一些相关的函数。 比如我们点击,Network.HTTP就会给我们一个详细的函数使用说明的网页,他接受什么类型,返回什么类型。 SimpleHTTP 接受一个Request 对象,然后返回一个IO Monad。
Prelude Network.HTTP> import Network.HTTP
Prelude Network.HTTP> :t simpleHTTP
simpleHTTP
:: HStream ty =>
 Request ty -> IO (Network.Stream.Result (Response ty))
Prelude Network.HTTP> let myRequest=getRequest "http://www.baidu.com"
Prelude Network.HTTP> simpleHTTP myRequest >>= getResponseBody 

>>=
Prelude Network.HTTP> :t (>>=)
(>>=) :: Monad m => m a -> (a -> m b) -> m b
>>=bind操作

Actually, go to https://wiki.haskell.org/Haskell, you will get resources you want.

Avatar
Ye Zhaoliang
Engineer of offshore wind turbine technique research

My research interests include distributed energy, wind turbine power generation technique , Computational fluid dynamic and programmable matter.

Related

本站访问量: