Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
lack of type safety in attributes #188
My first threepenny program had a bug that I was surprised was not prevented at the type level. Here it is:
The bug is that changing the value field of a UI.string has no effect, so the password strength estimate never gets displayed. The fix is changing "value" to "text".
Seems that it would be good improvement to only allow setting attributes that html elements actually have.
Type-safe HTML elements and attributes are a good idea, but the question is whether the implementation cost in terms of additional and maybe confusing type signatures is worth the benefit. At the moment, I lean towards the "sadly no" side, but I'm happy to be convinced otherwise by a prototype implementation.
A type-safe implementation of HTML combinators has been described in the paper
"A typed representation for HTML and XML documents in Haskell "
Of course, one doesn't have to go the "everything type-safe" route; it's also possible to encode just a few invariants which occur often in practice.