
Am 10/02/2015 um 04:02 PM schrieb Stefan Höck:
how can I express that two things are equal to each other without knowing the exact value and
how do I manage to make both assume a value once one of them becomes known.
I'm sure there are fancier ways to express such things, but you could use a placeholder (an Integer for instance, wrapped in a newtype) for the room reservation, together with a Map from Integer to Room to look up the room assigned to each reservation. As long as no room is assigned to a reservation number, a lookup in the map yields Nothing. Once a room is assigned, a lookup yields the room. All this should probably be wrapped up in the State Monad (the Map with the reservations being the state), so you don't have to carry around the Map explicitly.
Yes, this is what I would have done in imperative code and from your suggestion I understand that in haskell I'll have to carry that map around. So far so good. Here is another thought: In math it is terribly easy to express what I am after a simple "x=y" states that x and y are equal, but unknown. As soon as I add x=25, there is no more choice on the value of y. I guess I am after values which become more and more defined in the course of computation.