[英]Typechecking problems with pipes-attoparsec
我一直在嘗試管道式attoparsec,但運氣不高。
似乎在(似乎是)相對簡單的代碼中,Void和X之間存在類型不匹配。 從我在庫中閱讀的內容(在某些時候來看這將是類型同義詞),我不確定如何解釋類型錯誤。
測試代碼:
{-# LANGUAGE OverloadedStrings,RankNTypes #-}
module Main where
import qualified Data.Attoparsec.Char8 as A
import qualified Pipes as P
import qualified Pipes.Attoparsec as PA
import qualified Pipes.ByteString as PB
import qualified Pipes.Parse as PP
passthrough :: A.Parser PB.ByteString
passthrough = A.takeWhile (\s->True)
f :: Monad m => PP.StateT (P.Producer PB.ByteString m r) m (Either String String)
f = do
r <- PA.parse passthrough
return $ case r of
Left e -> Left "a"
Right (_,r1) -> Right "b"
g = PP.evalStateT f PB.stdin
h = P.runEffect g
這導致錯誤:
P.hs:16:8:
Couldn't match type `pipes-4.0.2:Pipes.Internal.Proxy
Data.Void.Void () () PB.ByteString m r0'
with `P.Proxy P.X () () PB.ByteString m r'
Expected type: PP.StateT
(PP.Producer PB.ByteString m r)
m
(Either PA.ParsingError (Int, PB.ByteString))
Actual type: PP.StateT
(pipes-4.0.2:Pipes.Core.Producer PB.ByteString m r0)
m
(Either PA.ParsingError (Int, PB.ByteString))
In the return type of a call of `PA.parse'
In a stmt of a 'do' block: r <- PA.parse passthrough
In the expression:
do { r <- PA.parse passthrough;
return
$ case r of {
Left e -> Left "a"
Right (_, r1) -> Right "b" } } Failed, modules loaded: none.
您需要升級到最新的pipes-attoparsec
,這將其pipes
依賴關系限制為4.1.*
。 我可以給你怎么樣,如果你列出你所安裝的版本,這可能會出現更詳細的信息pipes
, pipes-parse
和pipes-attoparsec
。 如果鍵入ghc-pkg list | grep pipes
ghc-pkg list | grep pipes
應該足夠了。
看起來您正在將pipes-4.1.0與版本pipes-attoparsec (或僅從錯誤消息無法確定的其他pipes- *軟件包)一起使用,期望使用pipes-4.0.2 。
如果同時安裝了舊版本和舊版本,則很有可能需要使用ghc-pkg hide
隱藏舊版本的pipes-attoparsec (或其他pipes- *軟件包)。 我有時不得不與其他軟件包一起執行此操作,但是我不清楚cabal / ghci / ghc如何進入需要的狀態。
使用ghc-pkg list | grep pipes-attoparsec
ghc-pkg list | grep pipes-attoparsec
可以查看已安裝的版本,並嘗試隱藏較舊的版本。 如果您只安裝了舊的,請使用cabal install獲得新的。
Void
與X
不匹配來自void包裝中的pipes-4.1.0 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.