dhall-nix-lib/NonEmpty/singleton.dhall

11 lines
313 B
Text

--| Create a `NonEmpty` list with just one element
let NonEmpty = ./Type.dhall
let singleton
: ∀(a : Type) → a → NonEmpty a
= λ(a : Type) → λ(x : a) → { head = x, tail = [] : List a }
let example =
assert : singleton Natural 2 ≡ { head = 2, tail = [] : List Natural }
in singleton