【发布时间】:2012-02-12 19:16:28
【问题描述】:
我有以下几种:
data Cheese = Cheddar Int | Edam String String | Cottage String Int
data Meal = Meal {
nameOfMeal :: String,
... other generic fields
cheese :: Cheese
}
目前我的表单如下所示:
cheddarForm = renderTable $ construct
<$> areq textField "Name of meal" Nothing
<*> areq intField "Cheddar fat" Nothing
where
construct name fat = Meal name (Cheddar fat)
我目前对以下事实感到非常满意,即每种“奶酪”都需要一种形式(尽管我当然不介意使用动态形式..)。但是,我真的很想摆脱以各种形式重复“用餐名称”。我可以以某种方式组合这些表格,还是我最终必须使用 Monadic 表格?
【问题讨论】: