sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
357 stars 72 forks source link

not selector cannot be applied to a refinement #239

Open Skyfold opened 2 years ago

Skyfold commented 2 years ago

The not selector can be applied to a selector :not(p) or to a refinement input:not(:checked), however the type signature for not is not :: Selector -> Refinement.

What I need is effectively not :: Either Selector Refinement -> Refinement, though it would not be nice to write input # not (Left checked). Ideally, I would like to write not p and input # not checked.

How would you like this implemented?

turion commented 2 years ago

Thanks for pointing this out!

The typical clay style for this is to create a new type class:

class Not a where
  not :: a -> Refinement

instance Not Selector where
...
instance Not Refinement where
...

So rather an open sum than a closed sum.

turion commented 2 years ago

Feel free to send a PR if you want :)