Hoogle Search
Within LTS Haskell 24.5 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
last :: IsNonEmpty f a a "last" => f a -> arelude Relude.List.NonEmpty O(n). Extracts the last element of a NonEmpty list. Actual type of this function is the following:
last :: NonEmpty a -> a
but it was given a more complex type to provide friendlier compile time errors.>>> last ('a' :| "bcde") 'e' >>> last [0..5 :: Int] ... ... 'last' works with 'NonEmpty', not ordinary lists. Possible fix: Replace: [Int] With: NonEmpty Int ... However, you can use 'last' with the ordinary lists. Apply 'viaNonEmpty' function from relude: viaNonEmpty last (yourList) Note, that this will return 'Maybe Int' therefore it is a safe function unlike 'last' from the standard Prelude ... >>> last (Just 'a') ... ... 'last' works with 'NonEmpty Char' lists But given: Maybe Char ...
last :: HasCallStack => [a] -> arelude Relude.Unsafe Extract the last element of a list, which must be finite and non-empty. WARNING: This function is partial. Consider using unsnoc instead.
Examples
>>> last [1, 2, 3] 3
>>> last [1..] * Hangs forever *
>>> last [] *** Exception: Prelude.last: empty list
last :: Monad m => Stream (Of a) m r -> m (Of (Maybe a) r)streaming Streaming.Prelude No documentation available.
last :: YiString -> Maybe Charyi-rope Yi.Rope Take the last character of the underlying string if possible.
-
base-compat-batteries Data.List.NonEmpty.Compat Extract the last element of the stream.
last :: forall (v :: Type -> Type) (n :: Natural) a . Vector v a => Vector v (n + 1) a -> avector-sized Data.Vector.Generic.Sized O(1) Yield the last element of a non-empty vector.
last :: forall (n :: Natural) a . Prim a => Vector (n + 1) a -> avector-sized Data.Vector.Primitive.Sized O(1) Yield the last element of a non-empty vector.
last :: forall (n :: Natural) a . Vector (n + 1) a -> avector-sized Data.Vector.Sized O(1) Yield the last element of a non-empty vector.
last :: forall (n :: Natural) a . Storable a => Vector (n + 1) a -> avector-sized Data.Vector.Storable.Sized O(1) Yield the last element of a non-empty vector.
last :: forall (n :: Natural) a . Unbox a => Vector (n + 1) a -> avector-sized Data.Vector.Unboxed.Sized O(1) Yield the last element of a non-empty vector.