elm-community / string-extra

String helper functions for Elm.

Home Page:http://package.elm-lang.org/packages/elm-community/string-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

String.Extra.prepend

aminnairi opened this issue · comments

It can be handy to have a method that add a string to the beginning of another.

For instance, when fetching the weather for a city and construction with a degres symbol.

temperature : String
temperature =
    weather.main.temp
        |> String.fromFloat
        |> String.Extra.prepend "°C"

Currently, the (++) operator would not be working for the same structure since it will be used as the second argument (and so append at the end, not at the beginning of the piped string).

temperature : String
temperature =
    weather.main.temp
        |> String.fromFloat
        |> (++) "°C" -- Leads to an error!