I’m Kristian, an Italian programmer, and I’m both new here in the community and new regarding the Elm language, but it feels just right to join the Elm community as you guys seem pretty kind to everyone and very passionate about Elm.
I have started learning Elm because it seems fast, clean and, in some ways, restrict you to one, at least general, way of doing/structuring things, bot via the language itself both with the guidelines written in the elm official guide. Also, its state about no runtime errors, provided by the core language constructs, is appealing.
I have now started a simple project, which you can discover publicly here on Github, just to get some better understanding of Elm by actually using it, about a single-page website which allows defining via UI n variables (each with some details, like, for example, name, value and colour) then selecting one or more from n predefined graph styles and then it will show the above variables plotted, or in a bar chart, etc. using the SVG library from the elm/svg package.
I’ve started with a single “Main” Elm file which describes the Html used within the page, like the inputs and links them to update the model so that the page knows the variables and the selected graphs. Then, based on this information, I would like to effectively draw some SVG graphs (I’m not using any graph-ready package on purpose, don’t even know if they exist at the moment).
Following the official guidelines, but obviously, I could have made and will make some mistakes on the road, I started by keeping the whole system simple and easy to read, then started to add complexity, also by making some refactoring, for which the compiler has been very useful.
I’m now at the very beginning of this project and, as soon as I started to write down functions to actually draw SVGs, the main Elm file started growing and I have started wondering if I could split the code so that (it sounds like a nice solution in my head) the main Elm file just handles the UI of the page and the state of variables and selected graphs, then it would correctly call some function from other modules for each graph (or type of graph). For example, if I want a plotter, I’m going to add a Plotter.elm module which knows how to draw a plot of some data, then the main Elm file would call it if I select the “plot” type graph on the website page. Then, if I would like bar charts, I would create a BarChart.elm file and so on (more or less).
The questions I’m facing right now are 3 ones.
Would, this solution, be correct and adheres to Elm official guidelines?
Since I have the variables (my data) typed in the main Elm file, how can I give the other modules the ability to “see” that data type if I also have to import the modules into my main Elm file? (read the article about circular dependency and how to avoid it, but I can only see the solution of creating a “Data.elm” file which I can import in all modules I need to, both drawing and main modules, solution n°2 in the article)
Since I would surely like to add some customization settings to the graphs (for example, in a bar chart I would like to see one variable above another or maybe I would like to change a variable colour only for a specific graph, etc.) where these customisations should be stored? Because, if I store them in the main Elm file, it should know about all the imported modules customisation settings and also maybe rendering them via Html, and if I store them in the drawing modules then I can’t precisely know which customisation is linked to which variable because I can edit variables on the main Elm file and have customisation settings for, just saying a deleted one. The linking seems too soft for me.
Thanks for your time,