/safeTail.idr Secret
Created
February 21, 2023 11:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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