我有以下类型:
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 表格?