Skip to content
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

Semigroup instance inverted #33

Open
Profpatsch opened this issue Jun 10, 2022 · 2 comments
Open

Semigroup instance inverted #33

Profpatsch opened this issue Jun 10, 2022 · 2 comments

Comments

@Profpatsch
Copy link

ghci> sconcat (First 'a' :| [First 'b'])
First {getFirst = 'a'}
ghci> sconcat ((Rec.rnil & Rec.rcons (#foo Rec.:= First 'a')) :| [(Rec.rnil & Rec.rcons (#foo Rec.:= First 'b'))])
[("foo","First {getFirst = 'b'}")]

I’d expect both to return the same result, since all I did was to wrap the First in a #foo field …

@Profpatsch
Copy link
Author

Oh, I think I get it: The values are not even looked at by the instance:

(Semigroup (Rec lts), UnsafeRecBuild lts lts (ConstC Monoid :: Symbol -> TYPE LiftedRep -> Constraint)) => Monoid (Rec lts)

lts here is completely opaque.

But that also means <> is equivalent of always throwing away the left record, no? Cause there is nothing to be done with the values.

@Profpatsch
Copy link
Author

Ah no, I missed the constraint ConstC Monoid, of course the values are looked at.

Better example:

> (rcons (#foo := "a") rnil) <> (rcons (#foo := "b") rnil)
[("foo","\"ba\"")]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant