私は次のタイプを持っています:
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)
私は現在、すべてのタイプの「チーズ」に 1 つのフォームが必要であるという事実に非常に満足しています (ただし、動的なフォームを使用してもかまいません..)。ただし、あらゆる形で「食事の名前」を繰り返すのは本当にやめたいと思います。どういうわけかフォームを組み合わせることができますか、それとも最終的にモナディックフォームを使用する必要がありますか?