jaspervdj / digestive-functors

A general way to consume input using applicative functors
149 stars 71 forks source link

Why the Monoid constraint on the error type? #157

Open moll opened 4 years ago

moll commented 4 years ago

Hey, I noticed https://github.com/jaspervdj/digestive-functors/pull/114 added Monoid constraints to a lot of functions. I don't understand why. Isn't the error type in Form error m value supposed to be for one error? The example check "Cannot be empty" (not . null) sure hints that, too. In that case, it makes no sense for the error type to have an identity element or even the Semigroup's combining. The errors function already returns a list, further hinting Monoid is redundant.

Thanks!

moll commented 4 years ago

I suspect this is related to the weird Applicative instance in http://hackage.haskell.org/package/digestive-functors-0.8.4.0/docs/src/Text.Digestive.Types.html#Result which caused the Monoid problem in #113 in the first place. If anything, Result looks like a semigroup, which is what the implementation of <*> seemed to be going for.

Related to https://github.com/jaspervdj/digestive-functors/issues/147.