2013-12-15 73 views
1

使用Snap開發Web應用程序時,我遇到了模糊類型的問題。Haskell Snap:query_ trouble

我的代碼是

getUserByUsrnamePwd :: Handler HaskellCalendar HaskellCalendar() 
getUserByUsrnamePwd = do 
    username <- getPostParam "username" 
    password <- getPostParam "password" 
    user <- query_ "SELECT * FROM users WHERE username = ? AND password = ?" (username, password) 
    liftIO $ print (user :: [User]) 

我得到一個錯誤

Expected type: (Maybe ByteString, Maybe ByteString) 
       -> Handler HaskellCalendar HaskellCalendar [User] 
    Actual type: (Maybe ByteString, Maybe ByteString) -> [r0] 

我真的不知道爲什麼,因爲根據API應該是(也許字節串,也許字節字符串),而不是(也許字節串,也許字節字符串) - > [R0]

此致

回答

1

來看b y documentation,它看起來像query_僅適用於不帶參數的查詢。你想要query

+0

謝謝。我也意識到了這一點。乾杯! –