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

Finishes #29: formatting for if-then-else chaining #34

Merged
merged 1 commit into from
Dec 24, 2021

Conversation

must-compute
Copy link
Contributor

I think this commit should finish the remaining step for this issue.

I'm not sure if produces pretty output in all cases. It seems fine so far, based on the examples below:

Input:

val x =
  if b1 then e1
  else if b2 then e2
  else if b3 then e3
  else if b4 then e4
  else if b5 then e5
  else if b6 then e6
  else if b7 then e7
  else e8


val y =
  if b1 then e1
  else if let val y = case z of foo => [1,2,3,4,5,6,8,9,10,11,12] | bar => [1,2,3,4,5,6,8,9,10,11,12] in baz end then e2
  else if b3 then e3
  else if b4 then e4
  else if b5 then e5
  else if b6 then e6
  else if b7 then e7
  else let val y = case z of foo => [1,2,3,4,5,6,8,9,10,11,12] | bar => [1,2,3,4,5,6,8,9,10,11,12] in baz end

Output:

val x =
  if b1 then
    e1
  else if b2 then
    e2
  else if b3 then
    e3
  else if b4 then
    e4
  else if b5 then
    e5
  else if b6 then
    e6
  else if b7 then
    e7
  else
    e8

val y =
  if b1 then
    e1
  else if
    let
      val y =
        case z of
          foo => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]
        | bar => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]
    in
      baz
    end
  then
    e2
  else if b3 then
    e3
  else if b4 then
    e4
  else if b5 then
    e5
  else if b6 then
    e6
  else if b7 then
    e7
  else
    let
      val y =
        case z of
          foo => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]
        | bar => [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]
    in
      baz
    end

@shwestrick
Copy link
Owner

Great! Looks good.

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

Successfully merging this pull request may close these issues.

2 participants