Skip to content

Code action to flatten a case expression's branch #4799

@giacomocavalieri

Description

@giacomocavalieri

Hello! One thing I wished I could do a couple of times is have a code action that would allow me to "flatten" a case expression branch when the only thing it's doing is pattern matching on a variable of the outer pattern... I think it's easier to explain with an example:

case wibble {
  Ok(a) ->
//   ^ If I have my cursor here
    case a {
//  ^^^^^^^ And maybe even here
      Wibble -> 1
      Wobble -> 2
      Woo -> 3
    }

  Error(_) -> -1
}

It would turn the case expression into:

case wibble {
  Ok(Wibble) -> 1
  Ok(Wobble) -> 2
  Ok(Woo) -> 3
  Error(_) -> -1
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions