Skip to content

Pipes in generated code are not on new lines since 4.2.1 #127

@WhileTruu

Description

@WhileTruu

I upgraded to 6.0.1 (from 4.1.1) and cli version 0.6.3 (from 0.5.2). The newer versions put line breaks in places that make the generated code harder to read.

From my testing, the change to generated code formatting happened in version 4.2.1; 4.2.0 was still putting each pipe on a new line.

Example:

Elm.declaration "hello"
            (Elm.string "123456"
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "1") (Elm.string "W"))
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "2") (Elm.string "o"))
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "3") (Elm.string "r"))
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "4") (Elm.string "l"))
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "5") (Elm.string "d"))
                |> Elm.Op.pipeTo (Gen.String.call_.replace (Elm.string "6") (Elm.string "!"))
            )

results in

hello : String
hello =
    "123456" |> String.replace "1" "W" |> String.replace
                                                  "2"
                                                  "o" |> String.replace
                                                                 "3"
                                                                 "r" |> String.replace
                                                                                "4"
                                                                                "l" |> String.replace
                                                                                               "5"
                                                                                               "d" |> String.replace
                                                                                                              "6"
                                                                                                              "!"

whereas for the equivalent generator code, 4.1.1 would generate

module HelloWorld exposing (..)


hello : String
hello =
    "123456"
        |> String.replace "1" "W"
        |> String.replace "2" "o"
        |> String.replace "3" "r"
        |> String.replace "4" "l"
        |> String.replace "5" "d"
        |> String.replace "6" "!"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions