elm/core

Maybe the pad functions in String should be removed?

dullbananas opened this issue · 5 comments

pad, padLeft, and padRight are probably not used very often and should be moved to String.Extra. They are mostly useful in terminal environments, not so much in browser

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

What evidence do you have?

padLeft at least is very useful to format zero padded integers (for example two digits month or day number).

Are there any other use cases for the pad functions? If not, this function could be implemented:

paddedFromInt : Int -> Int -> String
paddedFromInt digits =
    fromInt >> padLeft digits '0'

Usage:

paddedFromInt 5 32 == "00032"

I'm not sure what's your point.

This would replace a very versatile function by a limited single use case one whose signature and implementation is not simpler (and would actually use padLeft or equivalent under the hood, as you showed).

Any other use case would be ignored or would require a minor or major update to elm/core, and after a while, you would be back to padLeft to handle most use cases with a single generic function.

Are there any other use cases for the pad functions?

You might answer this question by analyzing their use in the thousands of Elm open source packages and applications available on GitHub (you can find them using the code search API). This would offer a better starting point for a discussion than assumptions based solely on intuition.