Search code examples
haskellyesod

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

gives the error,

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

The error line @ln-num#14 is mkYesod "App" [parseRoutesNoCheck|

I am sure, the error is to do with postWikiR#return $ RepJson $ toContent $ L.fromChunks bss. But not sure, how to fix?

Reference-1


Solution

  • Probably you are trying to run old code that does not work with current Yesod.

    You can get this to compile and run (ghc-7.10.1, yesod-1.4.1.5) with

    import Data.Enumerator (run_)
    ...
    bss <- run_ consume
    

    but I'm not sure what you want it to do. As is, it will return an empty list.