Hello All,
I am just getting myself to code in Haskell and would like to design advice. Below, I have a made up example:
data ClassRoom = ClassRoom { classRoomNo:: Integer, extra_fees::Float, students: Map StudentId Student}
data Student = Student {name::String, feesOwed::Float}
data StudentId = Integer
get_fees_owed classroom student_id = extra_fees + feesOwed $ (students classroom) M.! studentid
Here the `get_fees_owed` needs information from the container 'classroom'.
Here is my question/problem:
I believe I should model most of my code as expressions, rather than storing pre-computed values such as `fees_owed`. But,
defining expressions involve passing the container objects all over. For example, deep down in a function that deals with just
one `student`, I might need the fees owed information. Without, having a reference to the container, I cannot call get_fees_owed.
Also, I think it hinders composing of functions that just deal with one student at a time, but end up with some dependency on
the container.
I have several questions related to this design hurdle, but I will start with the one above.