faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

Add `--pretty-operators` flag #425

Closed michalseweryn closed 9 years ago

michalseweryn commented 9 years ago

Solve issue #366, plus some improvements of Printer

bergmark commented 9 years ago

Please fix these warnings

src/Fay/Types/Printer.hs:42:1: Warning:
    Top-level binding with no type signature:
      pwOutputString :: PrintWriter -> String

src/Fay.hs:30:1: Warning:
    The import of ‘Fay.Compiler.Print’ is redundant
      except perhaps to import instances from ‘Fay.Compiler.Print’
    To import instances alone, use: import Fay.Compiler.Print()
bergmark commented 9 years ago

Does this sound okay?

Thanks a lot for the PR, And special thanks for doing some cleanup, it's always hard to do that on external projects!

michalseweryn commented 9 years ago

Okay, I'll take a look at this today.

bergmark commented 9 years ago

Cheers!

michalseweryn commented 9 years ago

I was looking for some tests of --pretty flag, but I didn't find any. Maybe I should add some test of this flag as well?

bergmark commented 9 years ago

Sure, that'd be helpful as well!

bergmark commented 9 years ago

Another idea is to add a --pretty-all flag that enables all these options, would be convenient. I'm happy to merge this PR without that though!

michalseweryn commented 9 years ago

A about breaking changes, these are:

bergmark commented 9 years ago

This is great stuff!

Main.main = new $(function(){
  return _(_(Prelude["$"])(Prelude.print))(_(_(Prelude["++"])(Main.g))(Fay$$list("b")));
});

One thing I noticed is that it (understandably) doesn't prettify the operators built into the runtime, so you get Fay$$then, Fay$$add etc instead of e.g. Prelude[">>"]. It could probably be changed but I'm not sure if it's worth it since these functions are named already. Changing it would also mean that another layer of thunks would be added, which might make debugging harder.

Thank you so much!