I think some of this would require a dependent type system, which we don't
have. And while in this case, it would be really nice I can't imagine that
it is worth it.

Maybe a post processor that could do HTML sanity testing would be useful? I
can imagine using the Elm AST package and some kind of rules engine you
could build something like this, but it would be a different set of
constraints

Zach
ᐧ

On Sun, Jul 2, 2017 at 5:30 PM, Steve Schafer <st...@donacobi.us> wrote:

> Putting aside the practicality for a moment, a couple of things:
>
>
>    1. A distinction needs to be made between merely senseless and
>    prohibited by spec.For example, the *hr* element allows the *lang*
>    attribute, even though it makes no sense. We should not prohibit attributes
>    that make no sense if the spec allows them.
>    2. Whether or not an attribute is allowed by spec is not always
>    simple. For example, on the *a* element, the *target* attribute is
>    permitted, but only if the *href* attribute is also present.
>
>
> -Steve
>
>
> On Saturday, July 1, 2017 at 6:06:35 PM UTC-4, hivert.i...@gmail.com
> wrote:
>>
>> Hi everyone.
>>
>> 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.
>>
>> I was imagining simple cases :
>>
>> Html.a [ Html.Attributes.href "#" ] [] => compile
>> Html.a [ Html.Attributes.src "#" ] [] => does not compile
>> Html.img [ Html.Attributes.src "#"] [] => compile
>> Html.iframe [ Html.Attributes.src "#" ] [] => compile
>>
>> Obviously, this behavior should be extended to every attributes on every
>> HTML elements. 🙂
>> I was thinking about Phantom Types, but I can't figure a correct way to
>> do it.
>>
>> Anyone has an idea on what I should give a try?
>>
>> Just in case, I know the cost to do it will probably be higher than what
>> it actually, but, hey! Error checking at compile time is so good that no
>> trying it would be too bad!
>
> --
> 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 elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Zach Kessin
Teaching Web Developers to test code to find more bugs in less time
Skype: zachkessin
+972 54 234 3956 / +44 203 734 9790 / +1 617 778 7213

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to