digestive-functors

List of checkboxes with digestive-functors

拥有回忆 提交于 2019-12-10 02:25:04
问题 How do I use digestive functors to create a form that has a programmatically generated list of checkboxes, which would return a list. For example: [x] Milk [ ] Cereals [x] Ground meat would return ["Milk", "Ground meat"] . I'm expecting the type would be something like: form :: (Functor m, Monad m) => [String] -> HappstackForm m Html BlazeFormHtml [String] 回答1: There is no standard way to do so, but digestive-functors is highly composable using the Applicative interface, so you can easily

Validation spanning multiple fields

旧城冷巷雨未停 提交于 2019-12-08 19:17:54
问题 I'm trying to grok applicative forms, and I've been wondering how to implement a form that validates fields that depend on other fields. For example a registration form which has password and confirm_password fields and I'd like to validate that password == confirm_password . I could be done after the form has ran, in the handler, but that would mean losing error messages. Edit: Forgot to mention, I'm mainly using Yesods applicative forms, but they seem to be quite close to digestive-functors

Digestive Functors with a variable number of subforms (Snap/Heist)

落花浮王杯 提交于 2019-12-08 15:41:03
问题 I'm working on porting a site from PHP to Snap w/ Heist. I've ported some of the simpler forms to using Digestive Functors successfully, but now I have to do the tricky ones that require the use of subforms. This application manages producing flyers for retail stores, so one of the tasks that need to be done is adding an ad size and defining its physical dimensions on the printed flyer. Sizes will vary depending on the type of page (configurable by the flyer owner) and its orientation (which

List of checkboxes with digestive-functors

半腔热情 提交于 2019-12-05 02:15:48
How do I use digestive functors to create a form that has a programmatically generated list of checkboxes, which would return a list. For example: [x] Milk [ ] Cereals [x] Ground meat would return ["Milk", "Ground meat"] . I'm expecting the type would be something like: form :: (Functor m, Monad m) => [String] -> HappstackForm m Html BlazeFormHtml [String] There is no standard way to do so, but digestive-functors is highly composable using the Applicative interface, so you can easily create what you want. You can define a checkBox which returns a Maybe String , i.e. the name of the element if