jfmengels / elm-review-simplify

Provides elm-review rules to simplify your Elm code
https://package.elm-lang.org/packages/jfmengels/elm-review-simplify/latest/
BSD 3-Clause "New" or "Revised" License
20 stars 9 forks source link

Add Array.get on repeat and initialize simplifications #252

Closed morteako closed 9 months ago

morteako commented 9 months ago

Implements 4 simplifications for Array.get from #174

Array.get 2 (Array.repeat 10 x) -> Just x
 Array.get 100 (Array.repeat 10 x) -> Nothing
 Array.get 2 (Array.initialize 10 f) -> Just (f 2)
 Array.get 100 (Array.initialize 10 f) -> Nothing

Very open to code suggestions or other improvements. Sorry if just creating a PR out of nowhere is not the correct flow for contributions for this project

jfmengels commented 9 months ago

Hi @morteako :wave:

Thank you a lot for the pull request! :heart:

This looks really good to me!

(There were some conflicts in the changelog, so I've force-pushed onto your branch/fork, just saying this to avoid surprises)

Sorry if just creating a PR out of nowhere is not the correct flow for contributions for this project

It's fine. just note that if you're not fast enough then someone else might take start working on it, so the only downside is potentially someone wasting some time. Feel free to leave a comment in an issue if you want to tackle something in particular.