I am trying to migrate the library from Elm 0.15 to 0.16. The extension mechanism has been deleted.
My library offers physical calculations on bodies (represented as a record) and uses the record extension so that users can add labels and other metadata about bodies.
My sample code shows this use by adding a label to all bodies after they are created:
labeledBodies = map (\b -> { b | label = bodyLabel b.restitution b.inverseMass }) someBodies
This list of tagged bodies is also transferred to the library:
main = Signal.map scene (run labeledBodies tick)
What works: hardcoding a meta parameter in Body as follows:
type alias Body a = { pos: Vec2, -- reference position (center) velocity: Vec2, -- direction and speed inverseMass: Float, -- we usually use only inverse mass for calculations restitution: Float, -- bounciness factor shape: Shape, meta: a }
But this makes the API more awkward because it forces the helper functions to take an additional parameter. Is there a more elegant way to handle this change?
source share