data declaration with a kind signature is treated as an unprocessed comment #346

Open
opened 2021-04-23 22:53:19 +02:00 by cdparks · 0 comments
cdparks commented 2021-04-23 22:53:19 +02:00 (Migrated from github.com)

I'm using brittany-0.13.1.0 with ghc-8.10.4 on Ubuntu 18.04.5.

Given a module containing a data-declaration that has a kind signature:

module Thing
  ( Thing(..)
  ) where

data Which = This | That

data Thing (which :: Which) = Thing Int

and the following brittany.yaml:

Click to expand
---
conf_debug:
  dconf_roundtrip_exactprint_only: false
  dconf_dump_bridoc_simpl_par: false
  dconf_dump_ast_unknown: false
  dconf_dump_bridoc_simpl_floating: false
  dconf_dump_config: false
  dconf_dump_bridoc_raw: false
  dconf_dump_bridoc_final: false
  dconf_dump_bridoc_simpl_alt: false
  dconf_dump_bridoc_simpl_indent: false
  dconf_dump_annotations: false
  dconf_dump_bridoc_simpl_columns: false
  dconf_dump_ast_full: false
conf_forward:
  options_ghc:
    - -XBangPatterns
    - -XDataKinds
    - -XDeriveAnyClass
    - -XDeriveFoldable
    - -XDeriveFunctor
    - -XDeriveGeneric
    - -XDeriveLift
    - -XDeriveTraversable
    - -XDerivingStrategies
    - -XFlexibleContexts
    - -XFlexibleInstances
    - -XGADTs
    - -XGeneralizedNewtypeDeriving
    - -XKindSignatures
    - -XLambdaCase
    - -XMultiParamTypeClasses
    - -XNoImplicitPrelude
    - -XNoMonomorphismRestriction
    - -XOverloadedStrings
    - -XRankNTypes
    - -XRecordWildCards
    - -XScopedTypeVariables
    - -XStandaloneDeriving
    - -XTypeApplications
    - -XTypeFamilies
conf_errorHandling:
  econf_ExactPrintFallback: ExactPrintFallbackModeInline
  econf_Werror: false
  econf_omit_output_valid_check: false
  econf_produceOutputOnErrors: false
conf_preprocessor:
  ppconf_CPPMode: CPPModeAbort
  ppconf_hackAroundIncludes: false
conf_obfuscate: false
conf_roundtrip_exactprint_only: false
conf_version: 1
conf_layout:
  lconfig_reformatModulePreamble: true
  lconfig_altChooser:
    tag: AltChooserBoundedSearch
    contents: 3
  lconfig_allowSingleLineExportList: false
  lconfig_importColumn: 60
  lconfig_hangingTypeSignature: false
  lconfig_importAsColumn: 50
  lconfig_alignmentLimit: 1
  lconfig_indentListSpecial: true
  lconfig_indentAmount: 2
  lconfig_alignmentBreakOnMultiline: true
  lconfig_cols: 80
  lconfig_indentPolicy: IndentPolicyLeft
  lconfig_indentWhereSpecial: true
  lconfig_columnAlignMode:
    tag: ColumnAlignModeDisabled
    contents: 0.7

brittany fails with an error about an unprocessed comment:

$ stack exec brittany  -- --werror -v --output-on-errors --config-file brittany.yaml --write-mode inplace Thing.hs 
Error: detected unprocessed comments. The transformation output will most likely not contain some of the comments present in the input haskell source file.
Affected are the following comments:
(Comment "(" Thing.hs:7:12 Just AnnOpenP)

However, if I change the data declaration to a newtype:

 module Thing
   ( Thing(..)
   ) where

 data Which = This | That

-data Thing (which :: Which) = Thing Int
+newtype Thing (which :: Which) = Thing Int

then brittany succeeds:

$ stack exec brittany  -- --werror -v --output-on-errors --config-file brittany.yaml --write-mode inplace Thing.hs 
$ echo $?
0

Of course, this workaround can't be used when the original data-declaration has zero or more than 1 field.

I'm using `brittany-0.13.1.0` with `ghc-8.10.4` on Ubuntu 18.04.5. Given a module containing a `data`-declaration that has a kind signature: ```haskell module Thing ( Thing(..) ) where data Which = This | That data Thing (which :: Which) = Thing Int ``` and the following `brittany.yaml`: <details> <summary><b>Click to expand</b></summary> ```yaml --- conf_debug: dconf_roundtrip_exactprint_only: false dconf_dump_bridoc_simpl_par: false dconf_dump_ast_unknown: false dconf_dump_bridoc_simpl_floating: false dconf_dump_config: false dconf_dump_bridoc_raw: false dconf_dump_bridoc_final: false dconf_dump_bridoc_simpl_alt: false dconf_dump_bridoc_simpl_indent: false dconf_dump_annotations: false dconf_dump_bridoc_simpl_columns: false dconf_dump_ast_full: false conf_forward: options_ghc: - -XBangPatterns - -XDataKinds - -XDeriveAnyClass - -XDeriveFoldable - -XDeriveFunctor - -XDeriveGeneric - -XDeriveLift - -XDeriveTraversable - -XDerivingStrategies - -XFlexibleContexts - -XFlexibleInstances - -XGADTs - -XGeneralizedNewtypeDeriving - -XKindSignatures - -XLambdaCase - -XMultiParamTypeClasses - -XNoImplicitPrelude - -XNoMonomorphismRestriction - -XOverloadedStrings - -XRankNTypes - -XRecordWildCards - -XScopedTypeVariables - -XStandaloneDeriving - -XTypeApplications - -XTypeFamilies conf_errorHandling: econf_ExactPrintFallback: ExactPrintFallbackModeInline econf_Werror: false econf_omit_output_valid_check: false econf_produceOutputOnErrors: false conf_preprocessor: ppconf_CPPMode: CPPModeAbort ppconf_hackAroundIncludes: false conf_obfuscate: false conf_roundtrip_exactprint_only: false conf_version: 1 conf_layout: lconfig_reformatModulePreamble: true lconfig_altChooser: tag: AltChooserBoundedSearch contents: 3 lconfig_allowSingleLineExportList: false lconfig_importColumn: 60 lconfig_hangingTypeSignature: false lconfig_importAsColumn: 50 lconfig_alignmentLimit: 1 lconfig_indentListSpecial: true lconfig_indentAmount: 2 lconfig_alignmentBreakOnMultiline: true lconfig_cols: 80 lconfig_indentPolicy: IndentPolicyLeft lconfig_indentWhereSpecial: true lconfig_columnAlignMode: tag: ColumnAlignModeDisabled contents: 0.7 ``` </details> `brittany` fails with an error about an unprocessed comment: ```console $ stack exec brittany -- --werror -v --output-on-errors --config-file brittany.yaml --write-mode inplace Thing.hs Error: detected unprocessed comments. The transformation output will most likely not contain some of the comments present in the input haskell source file. Affected are the following comments: (Comment "(" Thing.hs:7:12 Just AnnOpenP) ``` However, if I change the `data` declaration to a `newtype`: ```diff module Thing ( Thing(..) ) where data Which = This | That -data Thing (which :: Which) = Thing Int +newtype Thing (which :: Which) = Thing Int ``` then `brittany` succeeds: ```console $ stack exec brittany -- --werror -v --output-on-errors --config-file brittany.yaml --write-mode inplace Thing.hs $ echo $? 0 ``` Of course, this workaround can't be used when the original `data`-declaration has zero or more than 1 field.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#346
There is no content yet.