Brittany fails to format code with type families #340

Open
opened 2021-02-08 12:08:58 +01:00 by vaclavsvejcar · 2 comments
vaclavsvejcar commented 2021-02-08 12:08:58 +01:00 (Migrated from github.com)

Hello,

it seems that current version of Brittany from master (6b4e53484014c7dc1e405a38e44e90e305d9a0e4), as well as the released 0.13.1.0 has some issues with formatting code containing type families, like this:

data Phase = Partial | Complete

type family (p :: Phase) ::: a where
  'Partial  ::: a = Last a
  'Complete ::: a = a

data UpdateCopyrightConfig (p :: Phase) = UpdateCopyrightConfig
  { uccSelectedAuthors :: p ::: Maybe (NonEmpty Text)
  }

This code compiles well, but when trying to format with brittany, I'm getting errors (at line starting with data UpdateCopyrightConfig) like these:

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 "(" src/Headroom/Configuration/Types.hs:212:28 Just AnnOpenP)
(Comment "(" src/Headroom/Configuration/Types.hs:243:21 Just AnnOpenP)
(Comment ")" src/Headroom/Configuration/Types.hs:243:32 Just AnnCloseP)
(Comment "(" src/Headroom/Configuration/Types.hs:278:22 Just AnnOpenP)
(Comment "(" src/Headroom/Configuration/Types.hs:310:20 Just AnnOpenP)
(Comment "(" src/Headroom/Configuration/Types.hs:361:19 Just AnnOpenP)
(Comment "(" src/Headroom/Configuration/Types.hs:419:20 Just AnnOpenP)

You can see the full affected source code here, as well as the entire project. Do you have any ideas what could be wrong here?

Thank you.

EDIT: Just for completenes, until now I used brittany built from commit a13ad1b and that one doesn't have this issue.

Hello, it seems that current version of Brittany from `master` (`6b4e53484014c7dc1e405a38e44e90e305d9a0e4`), as well as the released ` 0.13.1.0` has some issues with formatting code containing type families, like this: ```haskell data Phase = Partial | Complete type family (p :: Phase) ::: a where 'Partial ::: a = Last a 'Complete ::: a = a data UpdateCopyrightConfig (p :: Phase) = UpdateCopyrightConfig { uccSelectedAuthors :: p ::: Maybe (NonEmpty Text) } ``` This code compiles well, but when trying to format with brittany, I'm getting errors (at line starting with `data UpdateCopyrightConfig`) like these: ``` 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 "(" src/Headroom/Configuration/Types.hs:212:28 Just AnnOpenP) (Comment "(" src/Headroom/Configuration/Types.hs:243:21 Just AnnOpenP) (Comment ")" src/Headroom/Configuration/Types.hs:243:32 Just AnnCloseP) (Comment "(" src/Headroom/Configuration/Types.hs:278:22 Just AnnOpenP) (Comment "(" src/Headroom/Configuration/Types.hs:310:20 Just AnnOpenP) (Comment "(" src/Headroom/Configuration/Types.hs:361:19 Just AnnOpenP) (Comment "(" src/Headroom/Configuration/Types.hs:419:20 Just AnnOpenP) ``` You can see the full affected source code [here](https://github.com/vaclavsvejcar/headroom/blob/master/src/Headroom/Configuration/Types.hs), as well as the entire project. Do you have any ideas what could be wrong here? Thank you. __EDIT:__ Just for completenes, until now I used brittany built from commit `a13ad1b` and that one doesn't have this issue.
zlondrej commented 2021-02-23 16:52:54 +01:00 (Migrated from github.com)

Just encountered same issue. Looks like the problem is DataKinds.

SomeFile.hs:

{-# LANGUAGE DataKinds #-}
module SomeFile where

data SomeKind = KindA | KindB
data SomeType (kind :: SomeKind) = SomeType
--            ^ this is the cultprit

Error output:

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 "(" SomeFile.hs:5:15 Just AnnOpenP)
Just encountered same issue. Looks like the problem is `DataKinds`. `SomeFile.hs`: ``` {-# LANGUAGE DataKinds #-} module SomeFile where data SomeKind = KindA | KindB data SomeType (kind :: SomeKind) = SomeType -- ^ this is the cultprit ``` Error output: ``` 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 "(" SomeFile.hs:5:15 Just AnnOpenP) ```
simonvpe commented 2021-06-13 11:07:32 +02:00 (Migrated from github.com)

I'm experiencing this same issue too

I'm experiencing this same issue too
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#340
There is no content yet.