The way I envision this working is if there is no input, then the form succeeds with a value of Nothing. If there is input, then the validator runs. In the ultimate result, you'll have the fairly ugly Maybe (Maybe a) where the outer Maybe represents whether there were errors and the inner Maybe represents whether there was data. It's pretty easy to write this combinator for primitive fields, but it's more difficult for compound forms. I imagine the semantics would be that the final result would be Nothing only if all of the subforms were completely empty. Otherwise it would go to the validator.
I'm not sure whether could implement this by recursively changing all subforms to return Maybe values or if it would need an augmented Result type such as:
The way I envision this working is if there is no input, then the form succeeds with a value of Nothing. If there is input, then the validator runs. In the ultimate result, you'll have the fairly ugly
Maybe (Maybe a)
where the outer Maybe represents whether there were errors and the inner Maybe represents whether there was data. It's pretty easy to write this combinator for primitive fields, but it's more difficult for compound forms. I imagine the semantics would be that the final result would be Nothing only if all of the subforms were completely empty. Otherwise it would go to the validator.I'm not sure whether could implement this by recursively changing all subforms to return Maybe values or if it would need an augmented Result type such as: