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 on refinements? #53

Closed
ocharles opened this issue May 16, 2013 · 10 comments
Closed

Semigroup on refinements? #53

ocharles opened this issue May 16, 2013 · 10 comments

Comments

@ocharles
Copy link

I wanted to set outline-style:none for both a:active and a:visited, and thought I could do (":active" <> ":hover") & outlineStyle none, but Refinement is not a Monoid or Semigroup instance. In the end I did:

forM_ [":active", ":focus"] (& outlineStyle none)

Which does the job, but it is a tad verbose.

It also doesn't produce a:active, a:focus as I wanted, but instead gives me two separate blocks.

@jameshfisher
Copy link
Collaborator

I wanted to set outline-style:none for both a:active and a:visited

thought I could do (":active" <> ":hover")

forM_ [":active", ":focus"]

Just to clarify, should the :visited, :hover and :focus things be the same?

@jameshfisher
Copy link
Collaborator

Does this do what you wanted?

((a # active) <> (a # hover)) ? outlineStyle none

Refinement isn't a Monoid, but Selector is.

@ocharles
Copy link
Author

It does, but if I am already "in" a then I have to make another rule, which wasn't quite what I was expecting to do.

And yes, all of those pseudo selectors should have the same rules.

@jameshfisher
Copy link
Collaborator

icwym, I experienced this the other day.

@sebastiaanvisser
Copy link
Owner

Makes sense. You do want to be able to say a # (active <> hover), but this requires some additional machinery.

@jhenahan
Copy link
Contributor

I'm a bit curious about how you'd like this to work in certain cases.

With the trivial Monoid instance I'm playing with, this renders as a:active:hover, which is not what you want (and, strictly speaking, is ineffective since :hover must come before :active), but I think it fits the spirit of the Monoid better. I'm mainly thinking about cases likea:hover:last-child.

Conceptually, I think this is the right way to make Refinement a Monoid, but I'm open to being convinced that the split case is the better default.

@ocharles
Copy link
Author

I agree that what your suggesting. I can't say I gave the semigroup much thought, but seeing as pseudo selectors "stack" I'd be ok with your proposal.

@Profpatsch
Copy link

I stumbled over Refinements not being a semigroup, too. But I think what the OP wants is not what the instance should be: a:focus:hover selects all elements that are focused and hovered over (as far as I understand it).

So it would more sense to make it a commutative semigroup that combines its effects in that manner.

@turion
Copy link
Collaborator

turion commented Nov 17, 2019

I guess it would make sense to make Refinement a Semigroup, but I'm not sure I understand this well enough. PR welcome.

@github-actions
Copy link

Stale issue message

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

No branches or pull requests

6 participants