calico
calico copied to clipboard
Should `Modifier` be a typeclass?
The reasons I originally chose this design were:
- anything can be a
Modifier
(such as aString
,HtmlElement[IO]
, orSignal
) 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: https://github.com/armanbilge/calico/issues/203
- furthermore, they are harder to pass around. for example this is impossible
It is slightly mitigated by changes in: https://github.com/armanbilge/calico/pull/199 But still not so convenient.def MyComponent(mods: Mod[HtmlElement]*) = div( cls := "decoration", mods )