2016-09-24 4 views
1

여기에 haskell을 배우려고합니다. 이유를 묻지 마십시오. 아주 간단한 코드로 시작합니다. github에서도 복사했습니다.스택을 만들 수 없습니다.

name:    slack-client 
version:    0.1.0.0 
synopsis:   Initial project template from stack 
description:   Please see README.md 
homepage:   https://github.com/githubuser/slack-client#readme 
license:    BSD3 
license-file:  LICENSE 
author:    Author name here 
maintainer:   [email protected] 
copyright:   2016 Author name here 
category:   Web 
build-type:   Simple 
-- extra-source-files: 
cabal-version:  >=1.10 

library 
    hs-source-dirs:  src 
    exposed-modules:  Lib 
    other-modules:  Example 
    build-depends:  base >= 4.7 && < 5 
    default-language: Haskell2010 

executable slack-client-exe 
    hs-source-dirs:  app 
    main-is:    Main.hs 
    other-modules:  Example 
    ghc-options:   -threaded -rtsopts -with-rtsopts=-N 
    build-depends:  base 
        , HTTP 
        , HTTP-Simple 
        , slack-client 
    default-language: Haskell2010 

test-suite slack-client-test 
    type:    exitcode-stdio-1.0 
    hs-source-dirs:  test 
    main-is:    Spec.hs 
    build-depends:  base 
        , HTTP-Simple 
        , slack-client 
    ghc-options:   -threaded -rtsopts -with-rtsopts=-N 
    default-language: Haskell2010 

source-repository head 
    type:  git 
    location: https://github.com/githubuser/slack-client 

내가 어떤 생각이 내 .cabal 파일

slack-client-0.1.0.0: build 
Preprocessing library slack-client-0.1.0.0... 
[2 of 2] Compiling Example   (src\Example.hs, .stack-work\dist\b7fec021\ 
build\Example.o) 

D:\haskell\slack-client\src\Example.hs:3:1: error: 
    Failed to load interface for `Network.HTTP' 
    It is a member of the hidden package `HTTP-4000.3.3'. 
    Perhaps you need to add `HTTP' to the build-depends in your .cabal file. 
    Use -v to see a list of the files searched for. 

-- While building package slack-client-0.1.0.0 using: 
     C:\Users\Mihai\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\setup- 
Simple-Cabal-1.24.0.0-ghc-8.0.1.exe --builddir=.stack-work\dist\b7fec021 build l 
ib:slack-client exe:slack-client-exe --ghc-options " -ddump-hi -ddump-to-file" 
    Process exited with code: ExitFailure 1 

입니다

: 나는 stack build을 실행할 때 나는이 얻을, 그러나

module Example() where 

import Network.HTTP 

-- Non HTTPS 

-- 1. Perform a basic HTTP get request and return the body 
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 

:

그래서 코드는 이것이다 잘못하고있는거야? other-modules: Example : 당신이 당신의`예 모듈, 실행 파일의 일부가이 섹션

executable slack-client-exe 
    hs-source-dirs:  app 
    main-is:    Main.hs 

이 라인에 추가 할 경우

+0

'module example()'은'module Example'또는'module Example (get, getCode) where'을 읽어야합니다. 마찬가지로 당신은'Example'에서 아무 것도 내보내지지 않습니다 (그럼에도 불구하고 당신이 정의한 어떤 클래스 인스턴스도 클래스가 작동하는 특별한 방법 때문에 export 될 것입니다.) – Michael

+0

@Michael thanks! 그러나 문제가 해결되지는 않습니다. – Comforse

답변

1

.

당신이 라이브러리의 일부가 될하려는 경우,

library 
    hs-source-dirs:  src 
    exposed-modules:  Lib 

library 
    hs-source-dirs:  src 
    exposed-modules:  Lib, Example 

을 변경하고 cabal documentation를보십시오.

+0

모든 옵션을 시도했지만 동일한 오류가 발생했습니다. ''stack build'' 이외의 다른 것을 실행할 필요가 있습니까? – Comforse

+0

'Example.hs'를'src'로 옮기고'slack-client-exe'에 대해 스탠자에서 삭제 했습니까? 'Example'이 그것을 사용하기 때문에'build-depends'에'HTTP'를 추가해야합니다. 오류 메시지는'Network.HTTP' 모듈에 대해 알고 있지만'HTTP' 라이브러리가 언급되지 않았기 때문에 그것을 보는 것이 허용되지 않는다고 말하고 있습니다. – Michael