Question: **i used devexpress component**

i set data for **ItemSource** property of **GridControl** in code behhind like this :

```
grid.ItemsSource = query ;

```

query is List

when i filtered or searched in gridcontrol , display rows changed
now i want to get the changed itemsource like this : 

```
DataSource = ((IEnumerable)grid.ItemsSource).ToList();

```

How Can I do it ?

thanks

Answer: 
`mapM_` is useful for executing something only for its side effects. For example, printing a string to standard output doesn't return anything useful - it returns `()`. If we have a list of three strings, we would end up accumulating a list`[(), (), ()]`. Building this list has a runtime cost, both in terms of speed and memory usage, so by using `mapM_` we can skip this step entirely.

However, sometimes we need to execute side effects *and* build up a list of the results. If we have a function such as

```
lookupUserById :: UserId -> IO User

```

Then we can use this to inflate a list of `UserId`s to a list of `User`s:

```
lookupUsers :: [UserId] -> IO [User]
lookupUsers = mapM lookupUserById

```
In more general terms, the difference is that `mapM_` only needs to ["consume"](http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-Foldable.html#t:Foldable) all elements of the input, whereas `mapM` also needs to "re-build" the data structure, with new values. That's pretty much trivial for lists: you only need to [traverse](http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-Traversable.html) along the cons-cells, updating values with those received from the action you map. But it doesn't work that easily for containers whose structure depends on the actual contained values. So e.g. for `Data.Set` you can't define the equivalent of `mapM` with type `(a -> m b) -> Set a -> m (Set b)` – it is an instance of [`Foldable`](http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-Foldable.html#t:Foldable), but not of [`Traversable`](http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-Traversable.html#t:Traversable)