# Maybe identities

In the monoid lesson, we posed this question: If each of the following four functions is the `(<>)`

operation for a semigroup, what is the identity value that makes it a monoid?

`f1`

Identity value: `Nothing`

`f2`

Identity value: `Nothing`

`f3`

```
f3 :: Semigroup a => Maybe a -> Maybe a -> Maybe a
f3 (Just x) (Just y) = Just (x <> y)
f3 _ _ = Nothing
```

Identity value: `Just mempty`

This one was slightly a trick question, because we have to strengthen the constraint on `a`

from `Semigroup`

to `Monoid`

in order to ensure that this identity value exists.

Note that `Nothing`

is *not* an identity for this function! Remember the identity laws. For all `x`

:

`mempty <> x = x`

`x <> mempty = x`

Take, for example, `x = Just 1`

. Then `f3 Nothing (Just 1)`

is `Nothing`

, not `Just 1`

, therefore we know that `Nothing`

is not an identity.

`f4`

```
f4 :: Semigroup a => Maybe a -> Maybe a -> Maybe a
f4 (Just x) (Just y) = Just (x <> y)
f4 (Just x) Nothing = Just x
f4 Nothing (Just y) = Just y
f4 Nothing Nothing = Nothing
```

Identity value: `Nothing`