Hello, could you please fix the code, I have tried everything. The database module is HDBC.
getUser :: PostgresConnection -> String -> String -> Maybe User
getUser conn username password = do
result <- liftIO $ do
let myQuery = "SELECT * FROM users WHERE username=? AND password=?;"
select <- prepare conn myQuery
execute select [toSql username, toSql password]
fetchRow select
case result of
Just row -> do
let user = fromSqlRowToUser row
return user
Nothing -> do return (Nothing::Maybe User)
The error is with the last line that is supposed to return Nothing:
• Couldn't match type ‘Maybe User’ with ‘User’
Expected: Maybe User
Actual: Maybe (Maybe User)