Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format PrettyCCode.hs #242

Merged
merged 2 commits into from
Oct 8, 2015
Merged

format PrettyCCode.hs #242

merged 2 commits into from
Oct 8, 2015

Conversation

albertnetymk
Copy link
Contributor

camel_str='sub fun { ($var) = @_[0]; return $var if $var =~ /^[A-Z]/; $var =~ s/(?<=[a-z])_(\w)/\u$1/g; return $var; }; next if $_ =~ /^ *--/; s!((?<=[^"\w])|(?<=^))([\w_]+?)((?=[^"\w])|(?=$))!fun($2)!ge'
camel() { perl -pe $camel_str $@ }
camel_i() { perl -pi -e $camel_str $@ }
find ./src -type f -name '*.hs' | xargs zsh -i -c 'camel_i $@'

First commit is built using above scirpt; second commit is built by manually change the indentation.

@kikofernandez
Copy link
Contributor

why? isn't easier to just not write camel case?

@albertnetymk
Copy link
Contributor Author

Maybe the title is a bit misleading. Apparently, there's sth missing from the last PR on this issue. The scripts are the ones I used to construct this PR.

@kikofernandez
Copy link
Contributor

Ok I understand now. I will review this today

parens (pp_args args) $+$
(braced_block . pp') body
pp' (Function retTy name args body) = tshow retTy <+> tshow name <>
parens (ppArgs args) $+$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the script is pretty good but cannot deal with indentation issues, such as here, where the indentation is off by one char.

@kaeluka
Copy link
Contributor

kaeluka commented Oct 8, 2015

Thank you, @albertnetymk!

@kaeluka
Copy link
Contributor

kaeluka commented Oct 8, 2015

I assigned this to @kikofernandez, as he said he'd review.

@albertnetymk
Copy link
Contributor Author

The indentation is off-by-one, but still valid. It's not fixed on purpose, so that manual-editing and auto-editing is not mixed together.

@kaeluka
Copy link
Contributor

kaeluka commented Oct 8, 2015

You can make a second commit for the manual editing.

@kikofernandez
Copy link
Contributor

@albertnetymk I have been told (by @EliasC) to fix indentation issues many many times. I don't see why this should be different if we have spot it on time (before a merge). I agree with @kaeluka , create then a second commit with the right title.

@albertnetymk albertnetymk changed the title Auto snake to camel conversion on Haskell files format PrettyCCode.hs Oct 8, 2015
kaeluka pushed a commit that referenced this pull request Oct 8, 2015
@kaeluka kaeluka merged commit c53b5d1 into parapluu:master Oct 8, 2015
@kaeluka
Copy link
Contributor

kaeluka commented Oct 8, 2015

Awesome! :) <3

@kaeluka kaeluka deleted the camel branch October 8, 2015 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants