无法将类型Data.Enumerator.Internal.Iteratee与IO匹配

时间:2015-05-06 19:05:15

标签: haskell yesod

import qualified Data.ByteString.Lazy as L
import Data.Enumerator.List (consume)

data App = App
mkYesod "App" [parseRoutesNoCheck|
/*Texts WikR GET --PathMultiPiece handler for all combinations
/ WikiR POST
|]
instance Yesod App

getWikR :: [Text] -> Handler Text
getWikR parts = return "" --defaultLayout [whamlet||]

postWikiR = do
    bss <- lift consume
    return $ RepJson $ toContent $ L.fromChunks bss

main :: IO ()
main = warp 3000 App

给出错误,

yesod/hw.hs:14:1:
    Couldn't match type ‘Data.Enumerator.Internal.Iteratee
                           Data.ByteString.Internal.ByteString m0’
                  with ‘IO’
    Expected type: HandlerT App IO RepJson
      Actual type: HandlerT
                     App
                     (Data.Enumerator.Internal.Iteratee
                        Data.ByteString.Internal.ByteString m0)
                     RepJson
    In the first argument of ‘yesodRunner’, namely ‘postWikiR’
    In the expression:
      yesodRunner postWikiR env3739_adGV (Just WikiR) req3739_adGW

错误行@ ln-num#14为mkYesod "App" [parseRoutesNoCheck|

我确信,错误与postWikiR#return $ RepJson $ toContent $ L.fromChunks bss有关。但不确定,如何解决?

Reference-1

1 个答案:

答案 0 :(得分:1)

可能您正在尝试运行与当前Yesod不兼容的旧代码。

您可以使用

编译并运行(ghc-7.10.1,yesod-1.4.1.5)
import Data.Enumerator (run_)
...
bss <- run_ consume

但我不确定你想要它做什么。按原样,它将返回一个空列表。