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

No instance for Monoid Refinement #167

Closed
RamiroPastor opened this issue Apr 11, 2018 · 4 comments
Closed

No instance for Monoid Refinement #167

RamiroPastor opened this issue Apr 11, 2018 · 4 comments

Comments

@RamiroPastor
Copy link

RamiroPastor commented Apr 11, 2018

The code:

withPseudo :: String -> Refinement -> Css -> Css
withPseudo x y z =
  (byClass $ pack x) <> y & z

The error:

src/common/Tools/Css/Utils/Class.hs:22:3: error:
    • No instance for (Monoid Refinement) arising from a use of ‘<>’
    • In the first argument of ‘(&)’, namely ‘(byClass $ pack x) <> y’
      In the expression: (byClass $ pack x) <> y & z
      In an equation for ‘withPseudo’:
          withPseudo x y z = (byClass $ pack x) <> y & z
   |
22 |   (byClass $ pack x) <> y & z
   |   ^^^^^^^^^^^^^^^^^^^^^^^
@RamiroPastor
Copy link
Author

RamiroPastor commented Apr 11, 2018

Happens when importing only Clay, as well as when importing both Clay and Clay.Selector

@dbaynard
Copy link
Contributor

See #53

Just to be clear, you can sort of achieve what you seem to want with

withPseudo :: String -> Refinement -> Css -> Css
withPseudo x y z =
  star # byClass (pack x) <> star # y <? z

or better,

withPseudo :: Text -> Refinement -> Css -> Css
withPseudo class ref z =
  foldMap (star #) [byClass class. ref] <? z

Depending on what you're doing, you may wish to throw in a pop 1 $ immediately before the foldMap.

@RamiroPastor
Copy link
Author

I intended to do something like

withPseudo "some-class" (hover <> focus) $ do
  color red
  display inlineFlex

Simply because there seemed to be a Monoid instance for Refinement

@RamiroPastor
Copy link
Author

Ok, i just learned to do this, so im closing the issue:

  fontColor       white
  backgroundColor footerCol
  hover & backgroundColor crimson

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

2 participants