无法将类型 Data.Enumerator.Internal.Iteratee 与 IO 匹配
Couldn't match type Data.Enumerator.Internal.Iteratee with IO
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
有关。但不确定,如何解决?
可能您正在尝试 运行 不适用于当前 Yesod 的旧代码。
你可以用
编译和运行(ghc-7.10.1,yesod-1.4.1.5)
import Data.Enumerator (run_)
...
bss <- run_ consume
但我不确定你想要它做什么。照原样,它将 return 一个空列表。
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
有关。但不确定,如何解决?
可能您正在尝试 运行 不适用于当前 Yesod 的旧代码。
你可以用
编译和运行(ghc-7.10.1,yesod-1.4.1.5)import Data.Enumerator (run_)
...
bss <- run_ consume
但我不确定你想要它做什么。照原样,它将 return 一个空列表。