It’s definitely possible to do alternative things with the HTML syntax, but anything other than what we have will have a performance penalty. It’s unlikely we’ll support it in Halogen itself, but it could always be a library.
For what it’s worth, I think the theoretical example is no better at all than the bottom personally
, and the bottom one can be much improved by alternative formatting:
HH.div
[ HP.classes [ columns, isDesktop ] ]
[ HH.div
[ HP.class_ column ]
[ HH.h1
[ HP.class_ title ]
[ HH.text "TITLE" ]
, HH.button
[ HP.disabled: loading
, HE.onClick $ HE.input_ Click
]
[ HH.text "CLICK ME" ]
, someSolutionForFoo
]
]
Formatting this way takes a bit more space vertically but makes it much easier to see the structure.
Regarding foo, this kind of thing would be one option:
HH.div
[ HP.classes [ columns, isDesktop ] ]
[ HH.div
[ HP.class_ column ]
$ join
[ pure $ HH.h1
[ HP.class_ title ]
[ HH.text "TITLE" ]
, pure $ HH.button
[ HP.disabled: loading
, HE.onClick $ HE.input_ Click
]
[ HH.text "CLICK ME" ]
, guard foo $> HH.p_
[ HH.text "SURPRISE" ]
]
]
catMaybes would work here too, but with join you can have a guarded chunk of elements if you use *> instead of $>.
Or in this instance, since it’s the last element that is optional, you could just use a <> guard ... to avoid having to pure the join, etc.