> @Matthew -- re:

>

> while `Maybe a` is not necessarily a monoid, `Maybe [a]` *is*

>

> This seems to be a special case of a more general result, namely that if `Moo` is a monoid, then we can define a canonical monoid structure on `Maybe Moo`.

>

> The unit is `Nothing`, and we define `(Just x) <> (Just y)` to be `Just (x <> y)`.

You are absolutely right!

Haskell's defines the instance `Semigroup a => Semigroup (Maybe a)` in the [Prelude](https://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#line-406), following your specification:

And the *unit* for this monoid is defined in [Data.Monoid](https://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#line-422), again exactly as you suggest:

>

> while `Maybe a` is not necessarily a monoid, `Maybe [a]` *is*

>

> This seems to be a special case of a more general result, namely that if `Moo` is a monoid, then we can define a canonical monoid structure on `Maybe Moo`.

>

> The unit is `Nothing`, and we define `(Just x) <> (Just y)` to be `Just (x <> y)`.

You are absolutely right!

Haskell's defines the instance `Semigroup a => Semigroup (Maybe a)` in the [Prelude](https://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#line-406), following your specification:

instance Semigroup a => Semigroup (Maybe a) where

Nothing <> b = b

a <> Nothing = a

Just a <> Just b = Just (a <> b)

And the *unit* for this monoid is defined in [Data.Monoid](https://hackage.haskell.org/package/base-4.11.1.0/docs/src/GHC.Base.html#line-422), again exactly as you suggest:

instance Semigroup a => Monoid (Maybe a) where

mempty = Nothing