timjs / elm-collage

Create interactive vector graphics and position them relative to each other
BSD 3-Clause "New" or "Revised" License
58 stars 19 forks source link

Add shifting utils #23

Closed nikita-volkov closed 6 years ago

timjs commented 6 years ago

One of the things that were on my list, thank you!

I'd prefer however to have shiftX and shiftY be defined in terms of shift itself, instead of repeating the code. Could you fix that?

nikita-volkov commented 6 years ago

This isn't code duplication. What you suggest will incur a waste of performance on redundant operations like y + dy (where dy = 0), and packing/unpacking of a tuple. Elm won't optimize those away.

timjs commented 6 years ago

Yes, you're right, Elm is not Haskell yet unfortunately. As FP lovers we should be concerned about beautiful and reusable code more than about duplicating code for performance and let the inliner do its work. But Elm is not there yet.

I'll merge it and add a future note about inlining.