Skip to content

Add option for spaceless '{-|'#130

Merged
brandonchinn178 merged 2 commits intomainfrom
chinn/haddock
Aug 16, 2022
Merged

Add option for spaceless '{-|'#130
brandonchinn178 merged 2 commits intomainfrom
chinn/haddock

Conversation

@brandonchinn178
Copy link
Copy Markdown
Collaborator

@brandonchinn178 brandonchinn178 commented Nov 18, 2021

Blocked on #49?
Related to #74

It always kinda bothered me when multiline haddocks were formatted like

{- |
Some multiline
comment here
-}

The haddock documentation always uses {-| without the space

@georgefst
Copy link
Copy Markdown
Collaborator

Implementation looks good, but there's more to discuss before merging this.

I personally tend to use the existing style, though I really don't care either way. Could we perhaps get stats off Hackage for how popular each of the two is (I often see these sorts of stats in GHC proposals etc. - is there an easy way to grab the source of all packages / all popular/maintained packages)? This may need to be put behind a flag.

@brandonchinn178
Copy link
Copy Markdown
Collaborator Author

Yeah, I don't mind getting stats. Is there a tool people use to scrape Hackage?

@georgefst
Copy link
Copy Markdown
Collaborator

Is there a tool people use to scrape Hackage?

I don't know of any off-hand. I'd be interested to know if there is.

@brandonchinn178
Copy link
Copy Markdown
Collaborator Author

Kind reddit user pointed me to https://hackage-search.serokell.io, which seems to work. Unfortunately, as every package uses at least one of {- | or {-|, this basically boils down to loading all packages. I'll probably just write a script that goes through some of the popular packages and summarize the data that way

@brandonchinn178
Copy link
Copy Markdown
Collaborator Author

Ended up writing my own script for this: https://github.com/brandonchinn178/hackage-grep

Searching for {-| and {- | on the top 1000 packages on Hackage:

  • 138 packages use just {-|
  • 133 packages use just {- |
  • 75 packages use both

Note that if any of those packages use fourmolu, then some of the {- | matches might be false positives (if the author would have used {-| if not for fourmolu). But regardless, it seems like {- | is surprisingly (at least to me) used fairly often, so I'll hide this behind a flag.

@brandonchinn178 brandonchinn178 changed the title Special case '{-|' haddocks Add option for spaceless '{-|' Nov 28, 2021
@brandonchinn178 brandonchinn178 force-pushed the chinn/haddock branch 2 times, most recently from 7091a6c to df631f2 Compare January 23, 2022 08:02
@brandonchinn178 brandonchinn178 added the new config option Adds or would add new configuration option label Jan 24, 2022
@brandonchinn178 brandonchinn178 force-pushed the master branch 12 times, most recently from c7364ed to 40bcc74 Compare May 18, 2022 21:03
@brandonchinn178
Copy link
Copy Markdown
Collaborator Author

@georgefst FYI this is now behind a flag. Personally, because all official documentation uses {-|, I would be in favor of changing the fourmolu default to multi-line-compact. What do you think?

@georgefst
Copy link
Copy Markdown
Collaborator

@georgefst FYI this is now behind a flag. Personally, because all official documentation uses {-|, I would be in favor of changing the fourmolu default to multi-line-compact. What do you think?

I'm reluctant to change defaults without good reason. There are arguments on both sides. In particular, the reason I use the current style is consistency with single-line style: --| is actually a parse error.

@brandonchinn178
Copy link
Copy Markdown
Collaborator Author

Thanks @georgefst, I won't change the default. Good to merge, then?

@brandonchinn178 brandonchinn178 merged commit 51a8f53 into main Aug 16, 2022
@brandonchinn178 brandonchinn178 deleted the chinn/haddock branch August 16, 2022 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new config option Adds or would add new configuration option

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants