The Lessons of 14 Years of Open Source Haskell

Albert Krewinkel

BOB Feb 28, 2020

whoami

pandoc

Convert Markup

This is **important**!

$\|x + y\| \leq
\|x\| + \|y\|$

This is important!

x+yx+y\|x + y\| \leq \|x\| + \|y\|

Many Kinds of Documents

Markdown
⟷ DocBook ⟷ DokuWiki markup ⟷ EPUB ⟷ Emacs Muse ⟷ Emacs Org-Mode ⟷ FictionBook2 ⟷ HTML ⟷ Haddock markup ⟷ JATS ⟷ Jupyter notebook ⟷ LaTeX ⟷ LibreOffice ODT ⟷ MediaWiki markup ⟷ Microsoft Word docx ⟷ Textile ⟷ reStructuredText ⟷ roff man

Document AST

data Inline
    = Str Text
    | Space | SoftBreak | LineBreak
    | Emph [Inline]
    | Code Attr Text
    | Math MathType Text

Why Haskell?

Haskell logo

Contributions

+

Barrier of Entry

I don’t know enough Haskell to create a pull request.

Comparison Projects

Project Language Age SLOC
pandoc Haskell 14 53600
Sphinx Python 13 35100
Asciidoc Ruby 12 11700

Drive-By Contributors

Contributions are measured in git commits which touched core files.

Same-Same

Maximum numbers of commits per contributor.

Contributors

contributors by project

Language Popularity

Language popularity: taken from StackOverflow survey 2017.

Level of Involvement

Lines of code added per contributor

Non-code Contributions

Drawbacks

and their mitigation

Accommodate

Non-Haskell extensions

function Meta(m)
  m.date = os.date("%B %e, %Y")
  return m
end
[
  {"t": "Str", "c": "Hello,"},
  {"t": "Space"},
  {"t": "Str", "c": "World!"}
]

Libraries?

  • Then: sparse
  • Now: acceptable

Non-Standard

Again: why Haskell?

Haskell logo

Libraries!

Purity ⇒ Sanity

Testing

  • Unit tests
  • Property checks
  • Easy mocking

Refactoring

🏆

Case-Study: String to Text

data Inline
    = Str String
    | Space | SoftBreak | LineBreak
    | Emph [Inline]
    | Code Attr String
    | Math MathType String

Live-Demo

Wrapping up

Thanks

  • Vidar Holen
  • Joe Nelson
  • Christian Despres
  • Elisabeth Kant

John MacFarlane
and
everyone involved with pandoc

Support pandoc

GitHub

Summary

  • Leverage Haskell for its strengths.
  • Mitigate its weaknesses.
  • Plenty of talent around.
  • Use pandoc for all your document conversion needs.