Haskell 使用YesSOD,如何发送带有自定义HTTP状态代码的defaultLayout?
我尝试了以下方法:Haskell 使用YesSOD,如何发送带有自定义HTTP状态代码的defaultLayout?,haskell,yesod,Haskell,Yesod,我尝试了以下方法: sendResponseStatus status403 $ (defaultLayout [whamlet|Foo|] :: Handler Html) 这给了我这种类型的错误: <interactive>:1:1: Warning: Could not deduce (ToTypedContent (Handler Html)) arising from a use of ‘sendResponseStatus’ from the
sendResponseStatus status403 $ (defaultLayout [whamlet|Foo|] :: Handler Html)
这给了我这种类型的错误:
<interactive>:1:1: Warning:
Could not deduce (ToTypedContent (Handler Html))
arising from a use of ‘sendResponseStatus’
from the context (MonadHandler m)
bound by the inferred type of it :: MonadHandler m => m a
at <interactive>:1:1
In the expression: sendResponseStatus status403
In the expression:
sendResponseStatus status403
$ (defaultLayout
((asWidgetT . toWidget)
((blaze-markup-0.7.0.3:Text.Blaze.Internal.preEscapedText
. Data.Text.pack)
"Foo")) ::
Handler Html)
:1:1:警告:
无法推断(ToTypedContent(处理程序Html))
因使用“sendResponseStatus”而产生
从上下文(MonadHandler m)
由it的推断类型绑定::MonadHandler m=>MA
时间:1:1
在表达式中:sendResponseStatus status 403
在表达式中:
sendResponseStatus状态403
$(默认布局)
((asWidgetT.toWidget)
((blaze-markup-0.7.0.3:Text.blaze.Internal.preEscapedText)
.Data.Text.pack)
“Foo”)::
处理程序(Html)
事实证明,sendResponseStatus
不需要处理程序Html
,但普通Html
却可以:
html <- defaultLayout [whamlet|Foo|]
sendResponseStatus status403 html
html状态->mc->mb
sendResponseStatusHandler状态处理程序=do
响应
sendResponseStatusHandler :: (ToTypedContent c, MonadHandler m) => Status -> m c -> m b
sendResponseStatusHandler status handler = do
response <- handler
sendResponseStatus status response