Skip to content

Add modifier instance for tuple of modifiers#199

Merged
armanbilge merged 8 commits intomainfrom
pr/tuple-modifier
Feb 22, 2023
Merged

Add modifier instance for tuple of modifiers#199
armanbilge merged 8 commits intomainfrom
pr/tuple-modifier

Conversation

@armanbilge
Copy link
Copy Markdown
Owner

This generalizes the existing machinery in HtmlTag so that it can replicated more easily in userland e.g. to support:

def MyComponent[M](mods: M)(using Modifier[IO, HtmlDivElement[IO], M]) = 
  div(
    cls := "custom-class",
    otherMod1,
    otherMod2,
    mods
  )

h/t @yurique

@armanbilge
Copy link
Copy Markdown
Owner Author

Heh, this completely broke things 😅 not-so-gentle-reminded we need a test suite.

Comment on lines +78 to +81
private trait ModifierLowPriority:
given forFoldable[F[_], E <: fs2.dom.Node[F], G[_]: Foldable, A](
using M: Modifier[F, E, A]): Modifier[F, E, G[A]] =
(ga, e) => ga.foldMapM(M.modify(_, e)).void
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Unfortunately this is causing a lot of angst, because Tuple also has foldable instances. Sadly I wonder if I should remove it in favor of instances specifically for List and stuff.

Indeed, this is what caused the original bug when I attempted to implement this.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Replaced with a List-specific instance.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

... and Option instance too :) hopefully those are the main ones.

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.

1 participant