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

Should Modifier be a typeclass? #207

Open
armanbilge opened this issue Feb 21, 2023 · 0 comments · May be fixed by #234
Open

Should Modifier be a typeclass? #207

armanbilge opened this issue Feb 21, 2023 · 0 comments · May be fixed by #234
Labels
question Further information is requested UX Improve usability of an existing feature

Comments

@armanbilge
Copy link
Owner

The reasons I originally chose this design were:

  • anything can be a Modifier (such as a String, HtmlElement[IO], or Signal) without requiring implicit conversions, that are discouraged in Scala 3
  • typeclasses are more the Typelevel way

But there are some trade-offs:

  • they require the shapeless magic to work, so when you get it wrong the compiler errors can be quite intimidating and confusing
  • typeclasses are harder to understand, and take more boilerplate to implement your own instances. see also:
    Make it easier to implement custom modifiers #203
  • furthermore, they are harder to pass around. for example this is impossible
    def MyComponent(mods: Mod[HtmlElement]*) = 
      div(
        cls := "decoration",
        mods
      )
    It is slightly mitigated by changes in:
    Add modifier instance for tuple of modifiers #199
    But still not so convenient.
@armanbilge armanbilge added question Further information is requested UX Improve usability of an existing feature labels Feb 21, 2023
@armanbilge armanbilge linked a pull request Apr 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested UX Improve usability of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant