This is a partial function, it throws an error on empty lists. Use Data.List.unsnoc instead. Consider refactoring to use Data.List.NonEmpty.
\mathcal{O}(n). Extract the last element of a list, which must be
finite and non-empty.
To disable the warning about partiality put
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}
at the top of the file. To disable it throughout a package put the same
options into ghc-options section of Cabal file. To disable it in GHCi
put :set -Wno-x-partial -Wno-unrecognised-warning-flags into ~/.ghci
config file. See also the
migration guide.
Examples
Example1 expression
>>> last [1, 2, 3]3
Example1 expression
>>> last [1..]* Hangs forever *
Example1 expression
>>> last []*** Exception: Prelude.last: empty list