statebox / cql

CQL: Categorical Query Language implementation in Haskell
GNU Affero General Public License v3.0
162 stars 14 forks source link

Code formatting and styling #38

Open marcosh opened 5 years ago

marcosh commented 5 years ago

To avoid code written in too different styles, I would encourage the use of hlint and hindent and also compiling with stack --pedantic.

If you have any other styling rule you'd like to be followed, that would be nice to share

Update 2018-05-31 by @epost and @marcosh : https://www.tweag.io/posts/2019-05-27-ormolu.html and https://github.com/ennocramer/floskell

epost commented 5 years ago

Yesh! Glad you asked. This is work in progress but it does tackle some important points: https://hackmd.io/U8vrBv94TqK413F0GIEAfg.

We probably also want to use an .editorconfig file, see https://editorconfig.org.

What would be a good place to hook in your suggested linting?

marcosh commented 5 years ago

I'll take a look at editorconfig.

I'm using hlint and hindent at every save in my editor. I think that would be the best option (or anyway, anybody makes sures that he pushes code after linting it). Violations should be catched in code review.

Otherwise we could setup something which formats the code as soon as it is pushed, so we are sure that in code review everything is written nicely

epost commented 5 years ago

Yeah that seems like a good idea for now. I was thinking we could validate it during the automated build, but not sure how easy that is, since our .travis.yml basically only says 'use Nix'.

The .editorconfig would look something like this I guess:

# see https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
tg-x commented 5 years ago

There are also some tab warnings, see https://travis-ci.com/statebox/aql/builds/85998010

tg-x commented 5 years ago

oh the tab issue seems to be fixed already in master: https://travis-ci.com/statebox/aql/builds/86003480

epost commented 5 years ago

yeah I just merged Marco's commit.

tg-x commented 5 years ago

stack build --pedantic adds the -Wall -Werror flags, shall we put these in package.yaml so that it affects nix-build and thus Travis builds as well?

epost commented 5 years ago

Based on our rocketchat discussions of last night and before, we're investigating code formatters, and the extent to which they can help us produce readable code in the spirit of the stuff discussed above.

wisnesky commented 5 years ago

Is anyone besides me using a Mac? Getting ‘stack build’ to recognize ‘—pedantic’ would remove the cycle where I have to commit and push to read error messages from Travis CI.

On Oct 23, 2018, at 8:12 AM, Erik Post notifications@github.com wrote:

Based on our rocketchat discussions of last night and before, we're investigating code formatters, and the extent to which they can help us produce readable code in the spirit of the stuff discussed above.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

epost commented 5 years ago

@wisnesky Yep, moi. Let's try and figure that out. (I've heard some harsh criticism of Stack so this may be an example of how it's not so nice; I'm not sure.) Anyway, I created https://github.com/statebox/aql/issues/108 for this.