The provided findUserIdBySessionId function fails to compile
findUserIdBySessionId :: Redis r m => D.SessionId -> m (Maybe D.UserId)
findUserIdBySessionId sId = do
result <- withConn $ R.get (encodeUtf8 sId)
return $ case result of
Right (Just uIdStr) -> readMay . unpack . decodeUtf8 $ uIdStr
err -> throwString $ "Unexpected redis error: " <> show err
due to
• Could not deduce (MonadIO Maybe)
arising from a use of ‘throwString’
from the context: Redis r m
bound by the type signature for:
findUserIdBySessionId :: forall r (m :: * -> *).
Redis r m =>
D.SessionId -> m (Maybe D.UserId)
at src/Adapter/Redis/Auth.hs:37:1-71
• In the expression:
throwString $ "Unexpected redis error: " <> show err
In a case alternative:
err -> throwString $ "Unexpected redis error: " <> show err
In the second argument of ‘($)’, namely
‘case result of
Right (Just uIdStr) -> readMay . unpack . decodeUtf8 $ uIdStr
err -> throwString $ "Unexpected redis error: " <> show err’
|
42 | err -> throwString $ "Unexpected redis error: " <> show err
Pushing the return $ into the Right clause resolves this:
findUserIdBySessionId :: Redis r m => D.SessionId -> m (Maybe D.UserId)
findUserIdBySessionId sId = do
result <- withConn $ R.get (encodeUtf8 sId)
case result of
Right (Just uIdStr) -> return $ readMay . unpack . decodeUtf8 $ uIdStr
err -> throwString $ "Unexpected redis error: " <> show err
The provided
findUserIdBySessionIdfunction fails to compiledue to
Pushing the
return $into the Right clause resolves this: