joncfoo [5:00 PM]
qq, why does
V err a from
purescript-validation have a
Monoid requirement for
instance semigroupV :: (Semigroup err, Semigroup a) => Semigroup (V err a) where ... instance monoidV :: (Semigroup err, Monoid a) => Monoid (V err a) where ...
parsonsmatt [5:05 PM]
Monoid a for
you need a
a bc it does
Success a <> Success b = Success (a <> b)
joncfoo [5:10 PM]
sorry I should’ve phrased that better - why would you do this?
the commit that introduced this instance in 3.1.0 gives no rationale behind it - just a :party: emoji hah - https://github.com/purescript/purescript-validation/pull/12
natefaubion [5:44 PM]
@joncfoo what would an alternative be?
The commit just added the instance. Presumably it didn’t exist before.
joncfoo [5:49 PM]
I don’t know if there should be an alternative. I don’t think a general purpose validation type ought to have those requirements for
It’d be nice to at least have an explanation documented?
natefaubion [5:50 PM]
Sorry I didn’t mean an Alternative instance. I meant what would you do for the Monoid if you didn’t require a Monoid constraint on a?
The instance is only required if you use the instance
If you don’t try to use append on it, you won’t incur the requirement
joncfoo [5:53 PM]
Ah ok, thats ok then I think. I didn’t realise that the requirement wasn’t necessary if you don’t attempt to use it
monoidmusician [5:53 PM]
lift2 (<>) /
pure mempty is the “default” instance for applicatives
jkachmar [10:05 AM]
It’s especially useful if you want to
foldMap over validations
jkachmar [10:06 ]
If I’m just applying a set of rules and not transforming the input, I’ll sometimes make the result type
Unit and then
foldMap to run everything