Question: is there a way where a construct like (pseudo code):

```
test (a,b) = if a > 10 then a else null

```

in Haskell. If you map over a list I can use `filter` to do this, but I would like a similar construct using `if then else`.

Answer: 
All answers are good.. I just would like make a small addition by reminding that while pure functions are not able to do that, Haskell allows us to perform impure actions as well, for instance in the `IO` monad. There, we are more relaxed on doing such things .

```
test :: (Num a, Ord a, Show a) => (a,b) -> IO ()
test (a,b) = when (a < 10) $ print a

λ> test (11,"boru") -- nothing happens
λ> test (9,"boru")
9

```

kind of.
`if...else` is an expression in Haskell and must always evaluate to a value. Furthermore, both branches must evaluate to a value **of the same type**. So the `else` branch must evaluate to the same type as `a` for your code to work.

In the case of `filter`, the result must be a list. We can implement `filter` using `if...else`. The idea here is that if the condition is true, then we want to include the element in the resulting list. If not, then we want to continue filtering on the rest of the list.

```
filter _ [] = []
filter f (x:xs) = if f x then (x:f xs) else f xs

```

Note that in both cases, **the result is a list**. We remove an item by **not including it in the returned list**.