purescript-flame icon indicating copy to clipboard operation
purescript-flame copied to clipboard

Monoid instance for Html a

Open iclanzan opened this issue 2 years ago • 5 comments

Is it possible to give Html a a Monoid instance like React.Basic is doing for JSX?

iclanzan avatar Jan 14 '22 00:01 iclanzan

Hello @iclanzan , I am afraid I don't know what React.Basic uses monoids for. Is it a list like instance?

easafe avatar Jan 14 '22 00:01 easafe

https://pursuit.purescript.org/packages/purescript-react-basic/16.0.0/docs/React.Basic#t:JSX

JSX is a Monoid:

  • append Merge two JSX nodes using React.Fragment.
  • mempty The empty node; renders nothing.

Hint: Many useful utility functions already exist for Monoids. For example, guard can be used to conditionally render a subtree of components.

iclanzan avatar Jan 14 '22 01:01 iclanzan

I suppose this could be done. Though flame doesn't really have an equivalent to empty right now.

easafe avatar Jan 14 '22 01:01 easafe

I wonder if mempty = fragment [] would work.

iclanzan avatar Jan 14 '22 01:01 iclanzan

document.createFragment is currently used for fragments. I think it could work if treated as a special case.

easafe avatar Jan 14 '22 01:01 easafe