많은 실제 예제로 Cabal 패키지를 작성했습니다. 나는 예 디렉토리에서 이러한 예 중 하나를 복사하여 실행하려고 할 때, 나는 아래의 오류 얻을 : 도당 패키지 유형 서명 작업 때문에Haskell 추론 제약은 Cabal 패키지에서 작동하지만, 패키지에서 가져 오는 경우에는 적용되지 않습니다.
$ cabal sandbox init
$ cabal add-source deckbuild/
$ cabal install deckbuild/
$ cabal repl
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> :l GreedyInference.hs
[1 of 1] Compiling Main (GreedyInference.hs, interpreted)
GreedyInference.hs:93:27:
Could not deduce (mtl-2.1.3.1:Control.Monad.State.Class.MonadState
Game (StateT Game m))
arising from a use of ‘runGame’
from the context (MonadState Game m, MonadIO m)
bound by the type signature for
runGreedy :: (MonadState Game m, MonadIO m) =>
(Double, Double) -> m Game
at GreedyInference.hs:92:14-94
In the first argument of ‘execStateT’, namely ‘runGame’
In the expression: execStateT runGame
In the expression: execStateT runGame $ greedyGame ps
GreedyInference.hs:107:29:
No instance for (MonadState Game IO)
arising from a use of ‘runGreedy’
In the second argument of ‘($)’, namely
‘runGreedy (param0, param1)’
In the expression: unsafePerformIO $ runGreedy (param0, param1)
In an equation for ‘g’:
g = unsafePerformIO $ runGreedy (param0, param1)
Failed, modules loaded: none.
을, 나는 난 느낌이 가져 오기가 누락되었거나 패키지 외부의 코드를 사용할 때 형식 서명을 약간 조정해야합니다. 어떤 아이디어? 나는 올바른 방향으로 밀어 넣기를 찾고있을 뿐이며 구체적인 것을 파악할 수 있어야합니다. https://github.com/cronburg/deckbuild/blob/master/Examples/GreedyInference.hs
편집 :
작업 (패키지 내부에서 cabal repl
로드시) 모듈을 여기에서 찾을 수 있습니다
Control.Monad.State
에
Class
대
Lazy
함께 할 수있는 뭔가가 생각합니다. 추론은 어떤 이유로
Class
을 원하지만 hackage는
Lazy
이 기본값이라고 말합니다. 어느 것을 사용해야합니까? 그 이유는 무엇입니까?
'mtl-2.1.3.1'은'Game'에 대한 실제 인스턴스를 포함하는 패키지를 컴파일하는 데 사용했던 것과 동일한 버전의'mtl'입니까? 어떤 종류의 버전 충돌이 진행되고있는 것 같습니다. – Rufflewind
패키지 안에 'cabl repl'패키지가 있습니다 :'패키지 mtl-2.1.3.1 ... 연결 중 ... 완료되었습니다. ' – KarlC
'GreedyInference.hs'에 실제로 사용되는'mtl'의 버전은 무엇입니까? ('cabal repl -v'를 사용해보십시오.) – Rufflewind