I’m looking into Elm as a possible replacement for the frontend of the app I work on at my day job. It’s currently a messy pile of mostly-jQuery, with a lot of interpolation of values generated and written to the page by flask+jinja2. I understand that I can use
init to pass these interpolated values into my Elm model, but I’m unsure how to go about handling them beyond that.
As a for instance, we write the user id to the page, and then pass it in a header on AJAX requests. This user id won’t–and shouldn’t–change based on user activity, but it’s used everywhere. Given that I have more experience in Haskell than in Elm, my thoughts immediately go to the Reader monad, which allows config data like this to be effectively passed around without worrying about it getting messed with.
I realize that I could just put the user id etc. into my model and just nobody accidentally messes with it, but ‘hope nobody makes a boo-boo’ seems contrary to the spirit of Elm and similar languages. Is there a way to encode the immutability of these data in a way that the compiler would fuss if someone wrote a function that replaced them?