Code sample formatting I use here

You may have noticed that I mostly use <code> tags instead of the more conventional <pre> to signal source code. Although the <code> tag was invented to show HTML markup, and mostly one-liners of those too, I find them more convenient for two good reasons.

One is that I usually publish source code instead of prose, so using <code> is the semantically more appropriate one of the two. The second is a practical one: by definition, preformatted text does not support reflowing by the end user.

Although that does make sense in most cases, especially for layout-based languages like Haskell, however, introducing scroll-bars in small windows or on embedded devices is a major nuisance. Your layout is toast even if you only have one or two lines that are too wide in the source. Though, I do try to prevent the former case as much as possible.

This question is a usability issue, as in my opinion, it's much better to fiddle a bit with deciphering the one or two lines that got broken up than having to scroll back-and-forth horizontally in order to have an overview. Do keep in mind that in the first case, you only need to mentally connect the broken up line, while in the second case, you have to literally memorize the part of the code off the side!

Though, a minimal, user-agent based Haskell parser would help a lot in automatically desugaring layout, or even pretty printing the broken lines! :-)

Comments

Popular posts from this blog

Tftp secret of TL-WR740N uncovered

Hidden TFTP of TP-Link routers

Haskell for embedded: C output, compilers, monads, Timber