ppExpression :: Expression -> PP ()
ppExpression e =
  case e of
    Variable i -> ppIdentifier i
    New i e ->
      do write "new "
         ppIdentifier i
         write "("
         ppExpression e
         write ")"
    Function is e -> ppProcedure is [Return e]
    Procedure is ss -> ppProcedure is ss
    Apply e es ->
      do ppExpression e
         write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Conditional p y n ->
      do write "("
         ppExpression p
         write " ? "
         ppExpression y
         write " : "
         ppExpression n
         write ")"
    StrictEqual a b ->
      do ppExpression a
         write " === "
         ppExpression b
    Sequence es ->
      do write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Integer i -> write (T.pack (show i))
    Double d -> write (T.pack (show d))
    String s -> write (T.pack (ECMA.renderExpression (ECMA.StringLit () s)))

-- | Pretty print a function closure.
ppExpression :: Expression -> PP ()
ppExpression e =
  case e of
    Variable i -> ppIdentifier i
    New i e ->
      do write "new "
         ppIdentifier i
         write "("
         ppExpression e
         write ")"
    Function is e -> ppProcedure is [Return e]
    Procedure is ss -> ppProcedure is ss
    Apply e es ->
      do ppExpression e
         write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Conditional p y n ->
      do write "("
         ppExpression p
         write " ? "
         ppExpression y
         write " : "
         ppExpression n
         write ")"
    StrictEqual a b ->
      do ppExpression a
         write " === "
         ppExpression b
    Sequence es ->
      do write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Integer i -> write (T.pack (show i))
    Double d -> write (T.pack (show d))
    String s -> write (T.pack (ECMA.renderExpression (ECMA.StringLit () s)))

-- | Pretty print a function closure.
ppExpression e =
  case e of
    Variable i -> ppIdentifier i
    New i e ->
      do write "new "
         ppIdentifier i
         write "("
         ppExpression e
         write ")"
    Function is e -> ppProcedure is [Return e]
    Procedure is ss -> ppProcedure is ss
    Apply e es ->
      do ppExpression e
         write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Conditional p y n ->
      do write "("
         ppExpression p
         write " ? "
         ppExpression y
         write " : "
         ppExpression n
         write ")"
    StrictEqual a b ->
      do ppExpression a
         write " === "
         ppExpression b
    Sequence es ->
      do write "("
         intercalateM ", " (map ppExpression es)
         write ")"
    Integer i -> write (T.pack (show i))
    Double d -> write (T.pack (show d))
    String s -> write (T.pack (ECMA.renderExpression (ECMA.StringLit () s)))

-- | Pretty print a function closure.