【问题标题】:How to use $maybe in hamlet如何在 hamlet 中使用 $mabe
【发布时间】:2013-03-20 05:26:25
【问题描述】:

在 Yesod 中,我有一个填充类型的表单

data Field = Field Text Text text
  deriving Show

当我编写 hamlet html 来显示它时,我遇到了 Field 包裹在 Maybe Maybe Field 中的问题。所以在小村庄我正在尝试执行以下操作,如图所示here

(postHomeR 函数中的片段)

let fieldData = case result of
      FormSuccess res -> Just res
      _               -> Nothing

(在哈姆雷特文件中)

<ul>
  $maybe (Field one two three) <- fieldData
  <li>#{show one}

但是,编译时出现Not in scope: one 错误。为什么变量 one 没有正确创建/填充?

【问题讨论】:

    标签: haskell yesod hamlet


    【解决方案1】:

    您需要缩进

  • 以便它位于 $maybe 块内。就目前而言,它是 $maybe 的兄弟,因此 $maybe 绑定的变量不在范围内。
  • 【讨论】:

    • 非常感谢!其实我也是刚刚才发现的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    相关资源
    最近更新 更多