Skip to content

Formatter just weird in match case with many alternatives #940

@JonasWanke

Description

@JonasWanke

Input

is color := color %
  Black |
  Red |
  Green |
  Yellow |
  Blue |
  Magenta |
  Cyan |
  White |
  BrightBlack |
  BrightRed |
  BrightGreen |
  BrightYellow |
  BrightBlue |
  BrightMagenta |
  BrightCyan |
  BrightWhite -> True
  TrueColor [red, green, blue] -> int.isUnsignedByte red | bool.lazyAnd {int.isUnsignedByte green} | bool.lazyAnd {int.isUnsignedByte blue}
  _ -> False

Actual Output

is color := color %
  Black |   Red | 
  Green |   Yellow | 
  Blue |   Magenta | 
  Cyan |   White | 
  BrightBlack |   BrightRed | 
  BrightGreen |   BrightYellow | 
  BrightBlue |   BrightMagenta | 
  BrightCyan |  
    BrightWhite
    ->
    True
  TrueColor [red, green, blue] ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  Black | Red |   Green | Yellow | 
  Blue | Magenta |   Cyan | White | 
  BrightBlack | BrightRed |   BrightGreen | BrightYellow | 
  BrightBlue | BrightMagenta |  
    BrightCyan | 
    BrightWhite
    ->
    True
  TrueColor [red, green, blue] ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  Black | Red | Green | Yellow |   Blue | Magenta | Cyan | White | 
  BrightBlack | BrightRed | BrightGreen | BrightYellow |  
    BrightBlue | BrightMagenta | 
    BrightCyan | 
    BrightWhite
    ->
    True
  TrueColor [red, green, blue] ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  Black | Red | Green | Yellow | Blue | Magenta | Cyan | White |  
    BrightBlack | BrightRed | BrightGreen | BrightYellow | 
    BrightBlue | BrightMagenta | 
    BrightCyan | 
    BrightWhite
    ->
    True
  TrueColor [red, green, blue] ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  (
    Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | BrightBlack | BrightRed
  | BrightGreen
  | BrightYellow
  | BrightBlue
  | BrightMagenta
  | BrightCyan
  | BrightWhite
  )
    ->
    True 
    TrueColor [red, green, blue]
    ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | BrightBlack | BrightRed
  | BrightGreen
  | BrightYellow
  | BrightBlue
  | BrightMagenta
  | BrightCyan
  | BrightWhite 
    )
    ->
    True
    TrueColor [red, green, blue]
    ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
  _ -> False

# Then:

is color := color %
  Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | BrightBlack | BrightRed
  | BrightGreen
  | BrightYellow
  | BrightBlue
  | BrightMagenta
  | BrightCyan
  | BrightWhite
    )
    ->
    True
    TrueColor [red, green, blue]
    ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue } 
    _
    ->
    False

# Then:

is color := color %
  Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | BrightBlack | BrightRed
  | BrightGreen
  | BrightYellow
  | BrightBlue
  | BrightMagenta
  | BrightCyan
  | BrightWhite
    )
    ->
    True
    TrueColor [red, green, blue]
    ->
    int.isUnsignedByte red | bool.lazyAnd { int.isUnsignedByte green }
    | bool.lazyAnd { int.isUnsignedByte blue }
    _
    ->
    False

Desired Output

is color := color %
  Black
  | Red
  | Green
  | Yellow
  | Blue
  | Magenta
  | Cyan
  | White
  | BrightBlack
  | BrightRed
  | BrightGreen
  | BrightYellow
  | BrightBlue
  | BrightMagenta
  | BrightCyan
  | BrightWhite -> True
  TrueColor [red, green, blue] ->
    int.isUnsignedByte red | bool.lazyAnd {int.isUnsignedByte green}
    | bool.lazyAnd {int.isUnsignedByte blue}
  _ -> False

Relevant Logs

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions