Closed hejfelix closed 6 years ago
Thanks for reporting the issue
Ken Friis Larsen has a strict version of the algorithm in SML at https://github.com/kfl/wpp .
Now we're talking. Thanks! While I want this to be fixed, right now I need something that works 😀
Oh, I thought it was in idris :/
We have a Haskell library that looks astonishingly similar to Ken's that could potentially be ported to Idris: http://davidchristiansen.dk/drafts/final-pretty-printer-draft.pdf
No idea how to make it pass the totality checker, though. Perhaps it just will...
/David
Sorry, for delayed response. My port of Wadler-Leijens pretty print was a port of Shayam's version, and is not a strict version. It is total though... The lack of laziness could be addressed using the Lazy annotation, or changing the core algorithm to be strict. I don't have time to really address this, but PRs are welcome, and I am happy to guide people through the process.
oh, i've fixed this, awaiting tests to finish running
Man, so cool, thanks -- how would I understand which version of Idris would include this fix?
@hejfelix Currently the 'fix' is in the development version of Idris. Once a new release has been made, then you can get the library with the fix. Alternatively, you can check out the development version of idris and install contents of libs/
using the version of idris you have installed.
@jfdm
I'm trying to understand sources of complexity in the
PrettyPrint
module, and reading Wadler's article. On page 10 he states that lazy evaluation ofbest
s "inner computation" is essential for efficiency.I am unsure whether this can cause performance problems here: https://github.com/idris-lang/Idris-dev/blob/ec294a15690ead749f7ac77b2fc62adb366b6b84/libs/contrib/Text/PrettyPrint/WL/Core.idr#L162-L169
In my playing around with the library, I do see big performance dips on larger expressions that I cannot explain otherwise.
As an example, this expression doesn't terminate within any tolerable time:
The resulting doc from the fold is listed here: https://pastebin.com/4AJWcGnD