I'd like to keep track of a "current" value in a succession of immutable values. What is the best way to do that in Haskell without introducing a new reference for every new value? Here is an example:
data Person = Person {name, level, topic :: String }
deriving(Show)
dierk :: Person
dierk = Person "Dierk" "confident" "Java"
works :: Person -> String
works person = name person ++ " is " ++ level person ++ " in " ++ topic person
main _ = do
putStrLn $ works dierk
-- do more with "current" topic
putStrLn $ works dierk {level= "proficient", topic="Groovy"}
-- do more with "current" topic
putStrLn $ works dierk {level= "dabbling", topic="Haskell"}
-- do more with "current" topic