We could define a type for the attributes of each html element and pass
that as the list of attributes when defining the Html.

Html/Attributes.elm
type A msg = Href String | OnClick msg | ...

Html.elm
a : (List Html.Attributes.A msg) -> (List Html msg) -> Html msg

main.elm
Html.a [Html.Attributes.Href "#"] []

This would cause some naming woes for us, though, since both image and
iframe couldn't both have attributes named Src in the same package.  We
would either have to move them to separate packages or name them ImgSrc and
IframeSrc or the like.

On Sun, Jul 2, 2017 at 12:33 AM Peter Damoc <[email protected]> wrote:

> On Sat, Jul 1, 2017 at 9:35 PM, <[email protected]> wrote:
>
>> It's been some time that I'm thinking about type checking HTML Attributes
>> to ensure at compile time that useless attributes can't be set on HTML. For
>> instance, it makes no sense to set Html.Attributes.src to an h1 title.
>>
>
> To my understanding this restriction would have to be expressed in the
> type signature.
> How would the type signature for the `h1` would look like exactly?
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to