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: 
To filter a list with a predicate you could simply use `filter` like this

```hs
filter (>10) myList

```

but if you want to have a function that relectes in the output if the value was ok and returns the value, you can use the [`Maybe`](http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Maybe.html) type

```hs
test :: Int -> Maybe Int
test a = if a > 10 then Just a else Nothing

```

then you could filter with this function like this

```hs
catMaybes 
  $ map test
  $ myList

```

But if you just want to filter a list of values then you should use the first version with just a predicate that returns `Bool`
`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**.