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

Space before record body #21

Open
cblp opened this issue Sep 1, 2016 · 5 comments
Open

Space before record body #21

cblp opened this issue Sep 1, 2016 · 5 comments

Comments

@cblp
Copy link

cblp commented Sep 1, 2016

Should the space between record constructor or updated expression and record field list exist?

data Rec type1 = Rec{field1 :: type1, field2 :: Type2}
f x@Rec{field1} = x{field2 = field1}

or

data Rec type1 = Rec {field1 :: type1, field2 :: Type2}
f x@Rec {field1} = x {field2 = field1}

?

@cblp
Copy link
Author

cblp commented Sep 1, 2016

My personal voice contra the space.

Consider expression f x {...} or pattern F X {...}. They look like three space-delimited items, when are actually just two-item expressions. When I write f x{...} or F X{...} semantics is clear.

@cblp
Copy link
Author

cblp commented Sep 1, 2016

I invite @tibbe, @mrBliss, @chrisdone.

@tibbe
Copy link
Owner

tibbe commented Sep 1, 2016

I believe the common practice is to use a space but use parenthesis (or sometimes newlines, for big records) for clarity e.g. f (x {...}).

In general I try to capture common practice in the style guide. Perhaps you can check what popular packages (like aeson etc.) do.

@chrisdone
Copy link

Either F{...} or (F {...}) seem reasonable to me objectively speaking. Stylistically I have no preference.

@dpwiz
Copy link

dpwiz commented Sep 2, 2016

How about F{} vs (F {}) (constructor-only match)? Spaces and parens add more characters than the original construct has.

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

No branches or pull requests

4 participants