purescript-codegen / purescript-ps-cst

Purescript code printer, inspired by official purescript-cst types https://hackage.haskell.org/package/purescript/docs/Language-PureScript-CST-Types.html
BSD 3-Clause "New" or "Revised" License
10 stars 5 forks source link

Automatic multiline printing using prettyprinter #11

Closed srghma closed 4 years ago

srghma commented 4 years ago

Replaced boxes lib with this https://github.com/jmackie/purescript-prettyprinter/pull/3

srghma commented 4 years ago

@paluh @flip111 @jvliwanag the work is finished

you can check the tests to see the changes

Why prettyprinter?

this lib can automatically determine if expression needs to be printed in one-line (aka. flattened) or in multiline

What the experience of using prettyprinter is like

first, you write your code in a multiline fashion (vcat func for example), in respective places you use FlatAlt multilineDoc flattenedDoc constructor (e.g. vcat is using it internally)

then you wrap your inputDoc in group function so it flattens your inputDoc and constructs Union newFlattenedDoc inputDocNotChanged

Question to you guys?

do you mind if I create a fork of https://github.com/jmackie/purescript-prettyprinter with my changes in this organization,

since orignal author doesn't want to be involved https://github.com/jmackie/purescript-prettyprinter/issues/2 ?

srghma commented 4 years ago

actually I would even rename it to prettyprinter-renderable (because the implementation is different from haskell's version)

and publish ps-cst and prettyprinter-renderable (question is here https://github.com/jmackie/purescript-prettyprinter/issues/2#issuecomment-668634491 )

flip111 commented 4 years ago

do you mind if I create a fork of https://github.com/jmackie/purescript-prettyprinter with my changes in this organization,

Please go ahead with this. I can't do any more review at the moment since i'm very busy in personal life. Maybe in the fall or winter i and others can be more involved again. Thanks again for the great work !

srghma commented 4 years ago

Thx, will create repo later