+
Skip to content

Should Modifier be a typeclass? #207

@armanbilge

Description

@armanbilge

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    UXImprove usability of an existing featurequestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载