Haskell Snap: query_ trouble

101 views Asked by At

I got trouble with ambiguous type when developing web app with Snap.

My code is

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])

I got an error

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

I really don't know why because according to API it should be (Maybe ByteString, Maybe ByteString) rather than (Maybe ByteString, Maybe ByteString) -> [r0]

Kind Regards

1

There are 1 answers

1
Venge On BEST ANSWER

Judging by the documentation, it looks like query_ is only for queries that take no parameters. You want query.