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

Enable modifiers to be reified #234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Enable modifiers to be reified #234

wants to merge 1 commit into from

Conversation

armanbilge
Copy link
Owner

Closes #207.

This PR introduces Mod[IO, Elem] which reifies modifier, as well as a .toMod syntax.

This would make it possible to write:

def MyComponent(mod: Mod[IO, HtmlElement[IO]]) = 
  div(
    cls := "decoration",
    mod
  )

instead of

def MyComponent[M](mod: M)(using Modifier[IO, HtmlElement[IO], M]) = 
  div(
    cls := "decoration",
    mod
  )

and generally make it easier to pass modifiers around.

I'm not entirely sold on this yet, since it moves in the direction that Modifier should not be a typeclass, which in turn was motivated so that a .toMod extension wouldn't be needed for stuff like String or HtmlElement. But if we're going to do that anyway, then maybe we should change the encoding.

h/t @kubukoz, cc @yurique

Co-authored-by: =?UTF-8?q?Jakub=20Koz=C5=82owski?= <[email protected]>
/**
* A reified modifier
*/
trait Mod[F[_], E]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make E a type member and point it to Node[F]?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not, esp. if I go forward with proposed changes in #180 so that modifiers can only be applied to elements/nodes on which they are valid. Right now it's a bit wild west.

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

Successfully merging this pull request may close these issues.

Should Modifier be a typeclass?
2 participants