dhall-nix-lib/NonEmpty/last.dhall

12 lines
303 B
Text

λ(nix : ../NixPrelude.dhall) →
let NonEmpty = ./Type.dhall
let Optional/default = ../Optional/default.dhall nix
let last
: ∀(a : Type) → NonEmpty a → a
= λ(a : Type) →
λ(xs : NonEmpty a) →
Optional/default a xs.head (List/last a xs.tail)
in last