prettyPrintAlgebra (List []) = string "()"
prettyPrintAlgebra (List (firstDoc:docs)) =
  string "("
  <> firstDoc
  <> softline
  <> group (nest 2 (mconcat (intersperse softline docs)))
  <> string ")"

prettyPrintSExpr :: SExpr -> Doc
prettyPrintSExpr = fold prettyPrintAlgebra