# Building a Store without boilerplate The app that I’ve been building has a Store abstraction which is built on top of elm-phoenix (websockets). Typical methods in the API are:
Store.addProject projectAttributes store Store.renameProject projectId name store Store.deleteProject projectId store Store.getProjectUsers projectId store # relationship traversal The Store also handles latency compensation, so that for instance when you add a project it appears to the client that it has been added successfully even before a message has been sent to the server. Once the server confirms the operation is then confirmed/rejected in the client. While I'll happy with how the Store works, it does involved writing an absolute ton of boilerplate code. Every single method in the Store API needs to be hand written at every layer, updating the Store's internal model, the latency compensation and the serialisation. --- So the question is, in a statically typed language, with no introspection how would one go about avoiding this duplication? The two possibilities I've considered so far are: 1) Somehow do it in Elm, I'm struggling to see how it's possible, this would be my preferred option though :) 2) Define everything dynamically inside the Store, i.e. use Dicts everywhere instead of static types. Then provide the Store with a mapping which takes care of translating between the static and dynamic structures. Having to forgo static types is obviously disappointing with this route. 3) Code generation - lots of options here, could be inline macros in the Elm code, a custom DSL or code defined in another language. How would this sort of problem typically be solved in an ML language? Has anyone tried something similar in Elm? -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.