Haskell: Non-exhaustive patterns in function (simple functions) [duplicate]
问题 This question already has answers here : Better exception for non-exhaustive patterns in case (2 answers) Closed 4 years ago . I am confused as to why the 1st and 3rd versions of this functions give this error whereas the second definition works fine. -- head and tail third :: [a] -> a third [a] = head (tail (tail[a])) -- Pattern matching third2 :: [a] -> a third2 (_:_:x:_) = x -- List indexing third3 :: [a] -> a third3 [a] = [a]!!2 Thanks in advance 回答1: That is odd that the second one does