-
Notifications
You must be signed in to change notification settings - Fork 82
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
AST differs on Haddock comment on infix constructor #758
Comments
amesgen
added
bug
Something isn't working
comments
Issues related to comment placement
labels
Aug 11, 2021
6 tasks
I opened a GHC ticket for this: https://gitlab.haskell.org/ghc/ghc/-/issues/24221 But aside from that issue, it seems like Ormolu doesn't format a fully documented infix constructor correctly anyway. Here's an example: data Foo
= Int -- ^ Docs for left arg
:*: -- ^ Docs for constructor
Int -- ^ Docs for right arg This fails to output valid Haskell: <input>
@@ -1,4 +1,8 @@
data Foo
- = Int -- ^ Docs for left arg
- :*: -- ^ Docs for constructor
- Int -- ^ Docs for right arg
+ = -- | Docs for constructor
+
+ -- | Docs for left arg
+ Int
+ :*: -- | Docs for right arg
+ Int
+
AST of input and AST of formatted code differ.
at <input>:2:5-7
at <input>:2:9-30
Please, consider reporting the bug.
To format anyway, use --unsafe. |
3 tasks
FYI GHC 9.10 fixed the issue originally documented. But I'll fix the issue I brought up in the thread |
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this issue
Jan 31, 2025
## Fourmolu 0.17.0.0 * Add new `import-grouping` option to group imports with grouping rules specified in configuration ([#403](fourmolu/fourmolu#403)) * Add new `sort-constraints` option to sort constraints alphabetically ([#433](fourmolu/fourmolu#433)) * Add new `sort-derived-classes` option to sort classes in deriving clauses ([#434](fourmolu/fourmolu#434)) * Add new `sort-derived-clauses` option to sort classes deriving clauses ([#434](fourmolu/fourmolu#434)) * Add new `trailing-section-operators` option to disable trailing "section" operators (those that are `infixr 0`, such as `$`) ([#444](fourmolu/fourmolu#444)) * Fix issue where `single-constraint-parens: never` would drop parentheses around implicit parameters ([#446](fourmolu/fourmolu#446)) * Fix indentation for parenthesized expressions that start off the indentation column ([#428](fourmolu/fourmolu#428)) * Allow multiline comments in indented contexts ([#65](fourmolu/fourmolu#65)) ## Fourmolu 0.16.2.0 ### Upstream changes: #### Ormolu 0.7.7.0 * Use single-line layout for parens around single-line content. [Issue 1120](tweag/ormolu#1120). * Allow function arguments to be on the same line even if the full type (with constraints and foralls) are on multiple lines. [PR 1125](tweag/ormolu#1125). ## Fourmolu 0.16.1.0 ### Upstream changes: #### Ormolu 0.7.6.0 * Fix Haddock comments on infix constructors [Issue 758](tweag/ormolu#758). * Don't require a trailing newline in `.ormolu` files. [Issue 1122](tweag/ormolu#1122). * Remove unnecessary indentation from list comprehensions. [Issue 966](tweag/ormolu#966). ## Fourmolu 0.16.0.0 * Allow specifying path to configuration file with `--config` ([#396](fourmolu/fourmolu#396)) ### Upstream changes: #### Ormolu 0.7.5.0 * Switched to `ghc-lib-parser-9.10`, with the following new syntactic features/behaviors: * GHC proposal [#575](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0575-deprecated-instances.rst): deprecated instances. * GHC proposal [#281](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0281-visible-forall.rst): visible forall in types of terms. Enabled by `RequiredTypeArguments` (enabled by default). * `LinearTypes`: `let` and `where` bindings can now be linear, in particular have multiplicity annotations. * Using `forall` as an identifier is now a parse error. * GHC proposal [#65](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0065-type-infix.rst): namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas. * `TypeAbstractions` now supports `@`-binders in lambdas and function equations. * Support for the `GHC2024` language. * Updated to `Cabal-syntax-3.12`.
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this issue
Jan 31, 2025
## Ormolu 0.7.7.0 * Use single-line layout for parens around single-line content. [Issue 1120](tweag/ormolu#1120). * Allow function arguments to be on the same line even if the full type (with constraints and foralls) are on multiple lines. [PR 1125](tweag/ormolu#1125). ## Ormolu 0.7.6.0 * Fix Haddock comments on infix constructors. [Issue 758](tweag/ormolu#758). * Don't require a trailing newline in `.ormolu` files. [Issue 1122](tweag/ormolu#1122). * Remove unnecessary indentation from list comprehensions. [Issue 966](tweag/ormolu#966). ## Ormolu 0.7.5.0 * Switched to `ghc-lib-parser-9.10`, with the following new syntactic features/behaviors: * GHC proposal [#575](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0575-deprecated-instances.rst): deprecated instances. * GHC proposal [#281](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0281-visible-forall.rst): visible forall in types of terms. Enabled by `RequiredTypeArguments` (enabled by default). * `LinearTypes`: `let` and `where` bindings can now be linear, in particular have multiplicity annotations. * Using `forall` as an identifier is now a parse error. * GHC proposal [#65](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0065-type-infix.rst): namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas. * `TypeAbstractions` now supports `@`-binders in lambdas and function equations. * Support for the `GHC2024` language. * Updated to `Cabal-syntax-3.12`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
This snippet can't be formatted without
--unsafe
(minimized from Agda):With
--unsafe
, it is formatted toIn the first case, the Haddock comment is attached to the constructor
:#
, but in the second case, it is attached to the first argument of:#
.Expected behavior
It could be formatted like this to preserve the AST:
But this is not really nice from a sylistic perspective (we should not have to break apart an existing single line constructor variant).
Environment
Ormolu 0.2.0.0
Additional context
This changed in GHC 9.0; previously, both snippets had the same AST.
The text was updated successfully, but these errors were encountered: