Skip to content

Instantly share code, notes, and snippets.

@kuribas
Created February 21, 2023 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuribas/eada8c691e93e2b519dfb21959d9806e to your computer and use it in GitHub Desktop.
Save kuribas/eada8c691e93e2b519dfb21959d9806e to your computer and use it in GitHub Desktop.
data NonEmptyList : List a -> Type where
NonEmpty : NonEmptyList (x :: xs)
safeTail : (xs : List a) -> {auto prf : NonEmptyList xs} -> List a
safeTail (_ :: xs) = xs
test : List Int
test = [1, 2, 3]
-- type error, empty list
-- badTail : List Int
-- badTail = safeTail []
goodTail : List Int
goodTail = safeTail [1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment