-
Notifications
You must be signed in to change notification settings - Fork 13
Make V Monoid #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make V Monoid #12
Conversation
src/Data/Validation/Semigroup.purs
Outdated
@@ -70,3 +71,9 @@ instance applyV :: (Semigroup err) => Apply (V err) where | |||
|
|||
instance applicativeV :: (Semigroup err) => Applicative (V err) where | |||
pure = Valid | |||
|
|||
instance semigroupV :: (Semigroup err, Semigroup a) => Semigroup (V err a) where | |||
append x y = append <$> x <*> y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use lift2
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest: is lift2
faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not, but difference should be really small right?
Also javascript runtime could optimise lift2 if it's called too often.
src/Data/Validation/Semiring.purs
Outdated
@@ -77,6 +78,12 @@ instance applyV :: (Semiring err) => Apply (V err) where | |||
instance applicativeV :: (Semiring err) => Applicative (V err) where | |||
pure = Valid | |||
|
|||
instance semigroupV :: (Semiring err, Semigroup a) => Semigroup (V err a) where | |||
append x y = append <$> x <*> y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@paf31 @kritzcreek ping |
Thanks! |
No description provided.