Question: I have a list of tuples like this:

```
[("username", 123), ("df", 54), ("as",2 34)]

```

I need to search the value based on username. I have using lookup but i need to change the value of the integer and write back to file. My logic of this is to delete the tuple and insert another new tuple value rather than change it. 

Any idea how to do this ?

Answer: 
```
repList old new xs = map (\v@(x,y) -> if x == old then (new,y) else v) xs

```
If you use the Data.Map type you can use functions like 

```
updatedMap = Data.Map.updateWithKey (\_ _ -> Just 234) "username" myMap

```

With the way you give your list, you have to construct the map by something like

```
myMap = Data.Map.fromList (map (\ (a,b) -> (b,a)) datalist)

```

Finally, you can get things back to a list of values by using Data.Map.toList.