# NonEmpty.Types

**URL:** <https://forum.canton.network/t/nonempty-types/1190>\
**Category:** App Development\
**Created:** [September 10, 2020, 9:57am UTC](https://forum.canton.network/t/nonempty-types/1190 "2020-09-10T09:57:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carleslabon](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/carleslabon/32/6481_2.png) [@carleslabon](https://forum.canton.network/u/carleslabon)\
**Post date:** [September 10, 2020, 9:57am UTC](https://forum.canton.network/t/nonempty-types/1190/1 "2020-09-10T09:57:48Z")

</div>

Hello good evening, I would like to ask the use of NonEmpty.Types and also a sample code to better understand it’s usage, since I’m having a hard time looking for some reference.

Thanks!

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [September 10, 2020, 10:19am UTC](https://forum.canton.network/t/nonempty-types/1190/2 "2020-09-10T10:19:56Z")

</div>

@carleslabon have you had a look at the [`DA.NonEmpty` docs](https://docs.daml.com/daml/stdlib/DA-NonEmpty.html)?

The [page for `DA.NonEmpty.Types`](https://docs.daml.com/daml/stdlib/DA-NonEmpty-Types.html) really just gives you some insight into the `NonEmpty` type so you can pattern match on it better.

In short, `NonEmpty` is a nonempty list and you can treat it like a list in almost all cases. The difference is that functions like `head` are not partial, and that you need to pattern match differently. So instead of having to do constructs like

```haskell
case xs of
  [] -> ...
  hd::tl -> ...

```

you can just do

```haskell
let
  hd = xs.hd
  tl = xs.tl
...

```

or, of course use `xs.hd` and `xs.tl` directly.

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [September 10, 2020, 10:23am UTC](https://forum.canton.network/t/nonempty-types/1190/3 "2020-09-10T10:23:04Z")

</div>

Hi @carleslabon,

From [the documentation](https://docs.daml.com/daml/stdlib/DA-NonEmpty-Types.html) (emphasis mine):

> This module contains the type for non-empty lists so we can give it a stable package id. This is reexported from DA.NonEmpty so **you should never need to import this module**.

You can safely ignore the `DA.NonEmpty.Types` module. As @bernhard explained, `DA.NonEmpty` is really just there to add a type constraint on the fact that the list you expect is not empty.

---

<div class="post-metadata">

**Author:** ![carleslabon](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/carleslabon/32/6481_2.png) [@carleslabon](https://forum.canton.network/u/carleslabon)\
**Post date:** [September 10, 2020, 10:31am UTC](https://forum.canton.network/t/nonempty-types/1190/4 "2020-09-10T10:31:00Z")

</div>

Yes I had a look for DA.NonEmpty docs, I just thought that DA.NonEmpty.Types is a seperate module, haha. Thanks @bernhard!

---

<div class="post-metadata">

**Author:** ![carleslabon](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/carleslabon/32/6481_2.png) [@carleslabon](https://forum.canton.network/u/carleslabon)\
**Post date:** [September 10, 2020, 10:31am UTC](https://forum.canton.network/t/nonempty-types/1190/5 "2020-09-10T10:31:36Z")

</div>

Noted on this one, thanks @Gary_Verhaegen!
