Create upwards compatible APIs
Last updated
Was this helpful?
Last updated
Was this helpful?
How can I define my type, such that I can add features without breaking the API?
First write a constructor fromTitle
that only uses as few arguments as possible.
Next add partial constructors for every feature of your type: withRating
and withDirector
.
Now creating a new Movie
can be done like this:
📄Article: by Charlie Koster
🎥Video: by Brian Hicks
❗Example:
❗Example:
❗Example: from BrianHicks/elm-particle
❗Example: from dillonkearns/elm-graph
❗Example: from Orasund/pixelengine