在Yesod处理程序中使用Data.Binary.decodeFile

use*_*733 0 haskell yesod

我试着编译以下内容:

postRQuery :: Handler RepHtml
postRQuery = do
 properties <- liftIO $ decodeFile "store" :: IO (Map String ())
 defaultLayout [whamlet|Posted!|]
Run Code Online (Sandbox Code Playgroud)

但是我得到了以下编译器错误:

Couldn't match expected type `GGHandler
                              Bayith
                              Bayith
                              (Data.Enumerator.Iteratee
                               Data.ByteString.Internal.ByteString IO)
                              t0'
        with actual type `IO (Map String ())'
In a stmt of a 'do' expression:
    properties <- liftIO $ decodeFile "store" :: IO (Map String ())
Run Code Online (Sandbox Code Playgroud)

关于如何在Yesod处理程序中使用Data.Binary.decodeFile的任何想法?

ham*_*mar 6

这里的问题是优先权.::优先级低于$,因此解析为

properties <- (liftIO $ decodeFile "store") :: IO (Map String ())
Run Code Online (Sandbox Code Playgroud)

而你的意思是

properties <- liftIO (decodeFile "store" :: IO (Map String ()))
Run Code Online (Sandbox Code Playgroud)