Added CSS style and value modules to work with blaze-markup css branch #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This branch accompanies the proposed css branch in blaze-markup. For now, you'll have to clone both repositories and merge the
src/
directories if you want to test any of this. In other words,cabal build
won't work unless the sources in my css branch of blaze-markup are in thesrc/
directory. But see the postscript below.Along with some [slightly related] speed improvements, I proposed some minor changes in the conceptual model of an HTML element. I believe that all of these changes belong in either the blaze-html package or even in a separate blaze-css package altogether. Ideally, a Blaze syntax for CSS styles and classes would be part of a transformer stack on top of HTML and Markup layers. Maybe I'm just not good enough at this, but I really couldn't pull it off. I had to modify Internal.hs to get what I wanted.
An aside: In my humble opinion, the abstract model of elements in an HTML document would treat CSS styles and classes as equal in stature to HMTL attributes. The fact that both are transmitted as attribute values doesn't change the actual model. In practical terms, in an HTML document, a
font-family
might have been implemented as an attribute if something CSS-ish had been rolled into the HTML standard at the beginning.The problem: I found myself loathing the
that covered my sugary Blaze code like a rash. Yes, I know what a stylesheet is, but there is still a reason for the style attribute. Abusing
A.class_
was prettier only by a small margin, and the stylesheet has to react to every whim found in the Haskell code. The root problem is that attribute value builders forstyle
andclass
attributes are painful and ugly. I tried in vain to roll my own operators that worked well with(!)
until I decided to just promote styles and classes to the same rank as attribute.Now I get to write like this:
I understand that adding CSS functionality is a departure from the initial goal of producing markup with as little overhead as possible. But if the goal includes syntactic beauty, ease of use and raw speed - I think this has all of the above.
There's still work to do on non-String builders for Value.
Lastly, maybe someone could eventually work this CSS stuff into the BlazeFromHtml code. Probably not me.
P.S. For the authors: I'll set up a working copy of all the sources in blaze-builder, blaze-markup and blaze-html in a single repository to make it easier to see all of this together. I'm sure you have this already. But unless you're using a GIT_DIR trick or something to divide it all into multiple packages, it may be extra work for you to pull my work from multiple repositories. I'll put it at mikehat/blaze-all.