Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 使用YesSOD,如何发送带有自定义HTTP状态代码的defaultLayout?_Haskell_Yesod - Fatal编程技术网

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