# On \`none\` patterns

**URL:** <https://discourse.elm-lang.org/t/on-none-patterns/2730>\
**Category:** Request Feedback\
**Created:** [December 9, 2018, 6:12am UTC](https://discourse.elm-lang.org/t/on-none-patterns/2730 "2018-12-09T06:12:10Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ymtszw](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ymtszw/32/2360_2.png) [@ymtszw](https://discourse.elm-lang.org/u/ymtszw)\
**Post date:** [December 9, 2018, 1:36pm UTC](https://discourse.elm-lang.org/t/on-none-patterns/2730/6 "2018-12-09T13:36:33Z")

</div>

> [@allanderek](#):
>
> Having a `batch` value sort of also solves this problem. In your command example where you hypothetically do not have access to `Cmd.none` , you can always give `Cmd.batch []` as the `none` value (which is how `Platform.Cmd.none` is defined).

Very good point, thank you for bring it up!  
Yes, having `batch` function might actually be more generally helpful for this. As you pointed out,

- It IS actually a building block for `none` function
- Even without `none`, it allows us to do the equivalent by `batch []`
- **It essentially enables us to `flatten` Lists!!**

I found the 3rd point very interesting, related to code modularity.  
As we are already using `Cmd.batch` to do things like this:

```elm
fooCmd : Cmd Msg
fooCmd =
    Cmd.batch [fooDoThis, fooDoThat]

barCmd : Cmd Msg
barCmd =
    Cmd.batch [barDo]

rootCmd : Cmd Msg
rootCmd =
    Cmd.batch
        [ rootDoThis
        , rootDoThat
        , fooCmd
        , barCmd
        ]

```

(Of course we throw in `Cmd.map` when some of them are within their own `Msg` scope)

If inlined, it looks like:

```elm
rootCmd =
    Cmd.batch
        [ rootDoThis
        , rootDoThat
        , Cmd.batch
            [ fooDoThis
            , fooDoThat
            ]
        , Cmd.batch
            [ barDo
            ]
        ]

```

This `flatten`-ing is, although verbose and manual, quite powerful I think since it cannot be done with ordinary `List.flatten`.

---

_[View the full topic](https://discourse.elm-lang.org/t/on-none-patterns/2730)._
