Skip to content
  • David Feuer's avatar
    Make parsed AST dump output lazily · 29da01e0
    David Feuer authored
    Previously, `showAstData` produced a `String`. That `String` would
    then be converted to a `Doc` using `text` to implement
    `-ddump-parsed-ast`. But rendering `text` calculates the length
    of the `String` before doing anything else. Since the AST can be
    very large, this was bad: the whole dump string (potentially hundreds
    of millions of `Char`s) was accumulated in memory.
    
    Now, `showAstData` produces a `Doc` directly, which seems to work
    a lot better. As an extra bonus, the code is simpler and cleaner.
    The formatting has changed a bit, as the previous ad hoc approach
    didn't really match the pretty printer too well. If someone cares
    enough to request adjustments, we can surely make them.
    
    Reviewers: austin, bgamari, mpickering, alanz
    
    Reviewed By: bgamari
    
    Subscribers: mpickering, rwbarton, thomie
    
    GHC Trac Issues: #14161
    
    Differential Revision: https://phabricator.haskell.org/D3894
    29da01e0