2011-11-22 107 views
0

使用Data.Binary.decodeFile我試圖編譯如下:在耶索德處理

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

,但我得到了以下編譯器錯誤:我如何使用數據

​​

任何想法。 Yesod處理程序中的Binary.decodeFile?

回答

6

這裏的問題是優先。 ::$優先級高,所以這解析爲

properties <- (liftIO $ decodeFile "store") :: IO (Map String()) 

,同時你的意思是

properties <- liftIO (decodeFile "store" :: IO (Map String())) 
1

如果使用ScopedTypeVariables,你應該,你可以這樣做:

{-# LANGUAGE ScopedTypeVariables #-} 
(properties :: Map String()) <- liftIO $ decodeFile "store" 

但是,它好像你只是存儲密鑰,爲什麼不使用Data.Set.Set而不是地圖