【发布时间】:2014-05-12 21:59:46
【问题描述】:
我想在用户未登录时被重定向到登录页面时显示一条消息。
资源授权:
isAuthorized AdminR _ = isAdmin
isAuthorized _ _ = return Authorized
和
isAdmin = do
mu <- maybeAuthId
return $ case mu of
Just "Foo" -> Authorized
Just _ -> Unauthorized "You are NOT a Admin !"
Nothing -> do
setMessage "You have to Login "
return AuthenticationRequired
错误:
Couldn't match type `m0 AuthResult' with `AuthResult'
Expected type: m0 () -> m0 AuthResult -> AuthResult
Actual type: m0 () -> m0 AuthResult -> m0 AuthResult
In a stmt of a 'do' block: setMessage "You have to Login "
In the expression:
do { setMessage "You have to Login ";
return AuthenticationRequired }
In a case alternative:
Nothing
-> do { setMessage "You have to Login ";
return AuthenticationRequired }
那么,如何从 Monad 中提取 AuthResult ?
【问题讨论】: