relude-0.7.0.0: Safe, performant, user-friendly and lightweight Haskell Standard Library

Copyright(c) 2016 Stephen Diehl
(c) 2016-2018 Serokell
(c) 2018-2020 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Relude.List

Description

Utility functions to work with lists and NonEmpty lists.

Synopsis

Documentation

Most of the Data.List types and function.

Note, that list partial functions (e.g. head) are not exported from Data.List. Instead relude provides safe functions that work with NonEmpty. You can find them in the Relude.List.NonEmpty module instead.

Reexports from Data.List.NonEmpty and additional safe functions to work with list type in terms of NonEmpty.

(!!?) :: [a] -> Int -> Maybe a infix 9 Source #

Safer version of !!, returns a Maybe. get element from list using index value starting from `0`.

>>> [] !!? 0
Nothing
>>> ["a", "b", "c"] !!? 3
Nothing
>>> [1, 2, 3] !!? (-1)
Nothing
>>> ["a", "b", "c"] !!? 2
Just "c"

Since: 0.6.0.0