Use Data.Map like this :
import qualified Data.Map as Map
m1 :: Map String Int
m1 = Map.fromList [("username", 123), ("df", 54), ("as",234)]
Let's replace 54 by 78 (on "df"):
m2 = Map.insert "df" 78 m1
You can use insertWith' to combine the old and new values with a function.
Here we insert 4 on "username", and 4 is added to whatever value "username" points to.
m3 = Map.insertWith (+) "username" 4 m1
If you're sure that a key is in the map, you can access its value using the (!) operator :
import Data.Map ((!))
m3 ! "username"
Which gives 127
. But beware, it could raise an exception if the key isn't in the map!
For safe lookup :
Map.lookup :: Map k a -> k -> Maybe a
Map.lookup "usrname" m3
There is a typo on the key, so this returns Nothing
.