Is it feasible to implement a layout: false option? #317

Open
opened 2020-10-11 01:12:34 +02:00 by maralorn · 4 comments
maralorn commented 2020-10-11 01:12:34 +02:00 (Migrated from github.com)

Hey, thx for brittany!

I have some reasons to suspect that I could like it more to write my code with explicit { ; } style than relying on layout. Putting those symbols at the right spot is sometimes a lot easier, than fixing my alignment. After all for alignment I have brittany. </offtopic>

I have cloned brittany and started poking at the Layouters to see if I can get it to print explicit { ; }.

I can do it, when I put the ; in front of every line, by prepending it with docSeq.

I get code like this:

do {
   ; cursorUpLine writtenLines
   ; clearFromCursorToScreenEnd
   }

But I would also like to try to append it to every line, the bridoc documentation says I shouldn‘t, and alas when I try I get syntax errors (sadly brittany didn‘t tell me what syntax errors).

My questions:

  1. Is there a way to append a ; to the last line of a possible multi line statement and what do I need to do to not append it to a comment?
  2. Have you thought about this feature before, do you think it's feasible and do you have any tips?
Hey, thx for brittany! I have some reasons to suspect that I could like it more to write my code with explicit `{ ; }` style than relying on layout. Putting those symbols at the right spot is sometimes a lot easier, than fixing my alignment. After all for alignment I have brittany. `</offtopic>` I have cloned brittany and started poking at the Layouters to see if I can get it to print explicit `{ ; }`. I can do it, when I put the `;` in front of every line, by prepending it with `docSeq`. I get code like this: ```Haskell do { ; cursorUpLine writtenLines ; clearFromCursorToScreenEnd } ``` But I would also like to try to append it to every line, the bridoc documentation says I shouldn‘t, and alas when I try I get syntax errors (sadly brittany didn‘t tell me what syntax errors). My questions: 1. Is there a way to append a `;` to the last line of a possible multi line statement and what do I need to do to not append it to a comment? 2. Have you thought about this feature before, do you think it's feasible and do you have any tips?
tfausak commented 2020-11-15 19:00:03 +01:00 (Migrated from github.com)

I'm not exactly sure what you're asking for. Do you want Brittany to consume or produce code without layouting?

I'm not exactly sure what you're asking for. Do you want Brittany to consume or produce code without layouting?
maralorn commented 2020-11-15 21:49:56 +01:00 (Migrated from github.com)

Brittany can perfectly parse any code with or without layouting. The problem is, that it will then use layouting to print it again. So after formatting once all your { ; } is gone.

That's not a bug, but I was looking into making it possible to have an option for this.

Brittany can perfectly parse any code with or without layouting. The problem is, that it will then use layouting to print it again. So after formatting once all your `{ ; }` is gone. That's not a bug, but I was looking into making it possible to have an option for this.
tfausak commented 2020-12-11 17:59:04 +01:00 (Migrated from github.com)

It is possible to disable formatting entirely, which will preserve the explicit brackets and semicolons.

$ cat gh317.hs 
-- brittany-disable-next-binding
main = do { print 1; print 2 }

$ brittany gh317.hs 
-- brittany-disable-next-binding
main = do { print 1; print 2 }
It is possible to disable formatting entirely, which will preserve the explicit brackets and semicolons. ``` sh $ cat gh317.hs -- brittany-disable-next-binding main = do { print 1; print 2 } $ brittany gh317.hs -- brittany-disable-next-binding main = do { print 1; print 2 } ```
maralorn commented 2020-12-12 02:06:10 +01:00 (Migrated from github.com)

I didn‘t know about that option, although I searched for it for a while. Is it documented somewhere?

Anyways that is nice, but I’d still love to actually have formatting on blocks with braces.

So my initial question still stands, which is "How hard would it be, to get the formater to append a symbol to the last line of a multiline element."

I didn‘t know about that option, although I searched for it for a while. Is it documented somewhere? Anyways that is nice, but I’d still love to actually have formatting on blocks with braces. So my initial question still stands, which is "How hard would it be, to get the formater to append a symbol to the last line of a multiline element."
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#317
There is no content yet.