저는 하스켈을 처음 접했고, 나는 Happstack Crash Course을 따르려고합니다. 몇 가지 예제를 수행했지만 the happstack-heist example을 시도했을 때 이상한 컴파일 오류가 발생했습니다. 나는이 같은 모습을 컴파일하고있어 파일 :패키지 이름과 버전이 접두사로 붙은 형식 이름
module Main where
import Control.Applicative ((<$>))
import Control.Monad (msum)
import qualified Data.Text as T
import Happstack.Server (dir, nullConf, nullDir, simpleHTTP
, seeOther, toResponse
)
import Happstack.Server.Heist (heistServe, initHeistCompiled)
import Heist (Splices, (##), getParamNode, noSplices)
import Heist.Compiled (Splice, yieldRuntimeText)
import qualified Text.XmlHtml as X
-- | factorial splice
factSplice :: (Monad m) => Splice m
factSplice = do
intStr <- T.unpack . X.nodeText <$> getParamNode
let res = yieldRuntimeText $ do
case reads intStr of
[(n,[])] ->
return (T.pack $ show $ product [1..(n :: Integer)])
_ ->
return (T.pack $ "Unable to parse " ++
intStr ++ " as an Integer.")
return $ res
main :: IO()
main = do
heistState <- do
r <- initHeistCompiled (T.pack "fact" ## factSplice) noSplices "."
case r of
(Left e) -> error $ unlines e
(Right heistState) -> return $ heistState
simpleHTTP nullConf $ msum
[ dir "heist" $ heistServe heistState
, nullDir >>
seeOther "/heist/factorial" (toResponse "/heist/factorial")
]
오류는이 : 뭔가,하는 나는 돈을 패키지 이름과 버전 번호로 시작되는 유형을 원하는 것처럼
test.hs:37:36:
Couldn't match expected type `happstack-server-7.3.9:Happstack.Server.Internal.Types.Response'
with actual type `Happstack.Server.Internal.Types.Response'
In the return type of a call of `toResponse'
In the second argument of `seeOther', namely
`(toResponse "/heist/factorial")'
In the second argument of `(>>)', namely
`seeOther "/heist/factorial" (toResponse "/heist/factorial")'
보인다 이해하지 못해. 호 스택 - 서버와 호 스택 - 헤이스트 모두 cabal install
으로 설치되었습니다.
카발 샌드 박스를 사용하고 있습니까? – bheklilr
나는 그렇게 믿지 않지만, 나는 음모에 대해 많이 모른다. –
충돌하는 버전의 라이브러리가 설치되어 있고 컴파일러가 어느 것을 사용할지를 알지 못하는 것 같습니다 (이것은 하스켈 커뮤니티의 아픈 부분이며 많은 사람들이이를 잘 구현하는 방법에 대해 적극적으로 노력하고 있습니다). 이전 버전의'cabal' 패키지는 패키지를 설치할 수있는 프로젝트 별 패키지 데이터베이스를 설정하는 샌드 박스 ('cabal sandbox init'을 실행)를 추가했습니다. 이를 통해 각 프로젝트에 필요한 라이브러리 버전을 설치하고 전역 설치를 오염시키지 않아도됩니다. 파이썬의 경우 virtualenv와 같습니다. – bheklilr