yesodweb/yesod — Issue #213: Generalize formToAForm
Author: meteficha
Created: 2012-01-11 12:25:41+00:00
State: open

Hey!

Currently we have:

```haskell
formToAForm :: MForm sub master (FormResult a, FieldView sub master) -> AForm sub master a
formToAForm form = AForm $ \(master, langs) env ints -> do
((a, xmls), ints', enc) <- runRWST form (env, master, langs) ints
return (a, (:) xmls, ints', enc)
```

What I propose is:

```haskell
formToAForm :: MForm sub master (FormResult a, [FieldView sub master]) -> AForm sub master a
formToAForm form = AForm $ \(master, langs) env ints -> do
((a, xmls), ints', enc) <- runRWST form (env, master, langs) ints
return (a, (++) xmls, ints', enc)
```

Only the latter allows converting an `MForm` of multiple fields into a nice `AForm`. I don't see any drawbacks beside API breaks :).