We name it Style and then in layout, we say wrap : Style -> html -> html, link : Style -> {url, label} -> html, switch : Style -> {url, label, isChecked} -> html :-) :-) :-)
Disadvantage:
The only use case where one would want to use a different attribute type to draw links than Html.Attribute Never is if you use elm-w3 (a package that makes Html nodes and attributes as strict as the w3c spec). In that case, each element (a and area are the only elements that allow hrefs) needs to have the same attribute type anyways. So instead, we force total composability around links, even when that would violate the w3 spec.
Advantage:
Removing attribute simplifies the code
Discussion:
If there is a significant use case for Html.Attribute msg, then I'd prefer to parametrize Ui over msg instead.
If we want to support elm-w3, we need to support nested type narrowing
Implementation:
[x] Delete the attribute type parameter
[x] Extend the wrapper type parameter to handle Element
23
Proposal A: Hide the
attribute
type parameter which affects the Link element rendering, and make it default toHtml.Attribute msg
Proposal B: Introduce a type parameter
linker
analogous towrapper
, and inLayout
, add a fieldlink : linker -> html
.Proposal C: Replace the type parameter
wrapper
with a combined wrapper/linker that accepts either:Inserted | Removable | Removed
Node String (List Attribute) | Ul (List Attribute) |...
Link (List Attribute) {isInline, label}
The
layout
would connect Link and Switch via Link:and then you's write `toggle []...
No! Instead,
and then we
NO!
Here is correct:
We name it
Style
and then inlayout
, we saywrap : Style -> html -> html
,link : Style -> {url, label} -> html
,switch : Style -> {url, label, isChecked} -> html
:-) :-) :-)Disadvantage: The only use case where one would want to use a different
attribute
type to draw links thanHtml.Attribute Never
is if you useelm-w3
(a package that makes Html nodes and attributes as strict as the w3c spec). In that case, each element (a
andarea
are the only elements that allow hrefs) needs to have the same attribute type anyways. So instead, we force total composability around links, even when that would violate the w3 spec.Advantage: Removing
attribute
simplifies the codeDiscussion:
Html.Attribute msg
, then I'd prefer to parametrizeUi
overmsg
instead.Implementation:
attribute
type parameterwrapper
type parameter to handleElement