purescript-webrow / webrow

Let's build a highly opinionated but fully-featured web framework in PureScript
BSD 3-Clause "New" or "Revised" License
23 stars 0 forks source link

Try to switch `field` in the `Forms.Layout` representation by making it higher order type #9

Closed paluh closed 4 years ago

paluh commented 4 years ago

If we consider "MultiField" widgets which should be well typed - I mean contain specific and well structured access to its input and result we can think of switching in Forms.Layout.Layout from:

data Layout
  = Section ...
  | Field { field ∷ field, input ∷ input, result ∷ result }

into

data Layout field input result
  = Section ...
  | Field (field input result)

I hope that by requiring BiFoldable, BiTraversable and Bifunctor instances on this field we can provide sensible layout and form related implementations of the validation process, but not only for single value fields but also for such multifield widgets.

paluh commented 4 years ago

Another question which can be raised is - could we work with Variants in such a case and provide a preset of fields and widgets (like simple text input, multitext input) but allow extending this preset with custom types too but still provide the above instances implementation for our contrib subset.

paluh commented 4 years ago

We are using fully polymorphic field now without exposing input or result.