Converting between Bird-literate and plain Haskell

Literate programming is a good idea, and there exist many creative ways in which you could take advantage of it, like one described in Literate Haskell with Markdown and Syntax Highlighting.

However, if you're using the text editor Geany version 0.18, you will be faced with a bug that makes it unable to interpret Bird-style literate source. As a simple fix, I provide two programs to convert between simple Bird-literate and non-literate source code. You could also convert your Bird-literate to TeX-style.

# bird_lhs2hs
sed '
  s/^>//
  t
  s/^ *$//
  t
  s/^/-- /
 ' in.lhs > out.hs


# hs2bird_lhs
sed '
  s/^-- //
  t
  s/^ *$//
  t
  s/^/> /
 ' in.hs > out.lhs

Comments

Popular posts from this blog

Hidden TFTP of TP-Link routers

Tftp secret of TL-WR740N uncovered

When both Google *and* AppStatus is down