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

List in last line of do-block prevents formatting #296

Open
gutjuri opened this issue Apr 16, 2020 · 1 comment
Open

List in last line of do-block prevents formatting #296

gutjuri opened this issue Apr 16, 2020 · 1 comment

Comments

@gutjuri
Copy link

gutjuri commented Apr 16, 2020

I have the following function:

wnums :: [Double] -> [Double]
wnums nums = do
  a  <- nums
  b  <- nums \\ [a]
  c  <- nums \\ [a, b]
  d  <- nums \\ [a, b, c]
  o1 <- opts
  o2 <- opts
  o3 <- opts
  [   (a `o1` b) `o2` (c `o3` d)
    , ((a `o1` b) `o2` c) `o3` d
    , a `o1` (b `o2` (c `o3` d))
    , (a `o1` (b `o2` c)) `o3` d
    , a `o1` ((b `o2` c) `o3` d)
    ]

This function compiles but when i run brittany on the source file then it errors out with ERROR: brittany pretty printer returned syntactically invalid result.

Without this function the source file can be reformatted just fine.

@tfausak
Copy link
Collaborator

tfausak commented Apr 16, 2020

Sounds related to #290, in that formatting things in do notation is different that regular code. Here's what Brittany 0.12.1.1 outputs (using --output-on-errors):

ERROR: brittany pretty printer returned syntactically invalid result.
wnums :: [Double] -> [Double]
wnums nums = do
  a  <- nums
  b  <- nums \\ [a]
  c  <- nums \\ [a, b]
  d  <- nums \\ [a, b, c]
  o1 <- opts
  o2 <- opts
  o3 <- opts
  [ (a `o1` b) `o2` (c `o3` d)
  , ((a `o1` b) `o2` c) `o3` d
  , a `o1` (b `o2` (c `o3` d))
  , (a `o1` (b `o2` c)) `o3` d
  , a `o1` ((b `o2` c) `o3` d)
  ]

As a workaround, you can pass the list to a function like id. Or you can explicitly build the list using (:).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants