data List :: * -> *
(Show a) => Show (List a)
(Eq a) => Eq (List a)
Semigroup (List a)
Monoid (List a)
Functor List
Foldable List
Unfoldable List
Traversable List
Apply List
Applicative List
Bind List
Monad List
Alt List
Plus List
Alternative List
MonadZero List
MonadPlus List
nil :: forall a. List a
cons :: forall a. a -> List a -> List a
infixr 6 cons as :
toUnfoldable :: forall f a. Unfoldable f => List a -> f a
Convert a list into any unfoldable structure.
Running time: O(n)
fromFoldable :: forall f a. Foldable f => f a -> List a
Construct a list from a foldable structure.
Running time: O(n)
singleton :: forall a. a -> List a
Create a list with a single element.
Running time: O(1)
infix 8 range as ..
An infix synonym for range
.
range :: Int -> Int -> List Int
Create a list containing a range of integers, including both endpoints.
null :: forall a. List a -> Boolean
Test whether a list is empty.
Running time: O(1)
length :: forall a. List a -> Int
Get the length of a list
Running time: O(n)
head :: forall a. List a -> Maybe a
Get the first element in a list, or Nothing
if the list is empty.
Running time: O(1)
.
last :: forall a. List a -> Maybe a
Get the last element in a list, or Nothing
if the list is empty.
Running time: O(n)
.
tail :: forall a. List a -> Maybe (List a)
Get all but the first element of a list, or Nothing
if the list is empty.
Running time: O(1)
init :: forall a. List a -> Maybe (List a)
Get all but the last element of a list, or Nothing
if the list is empty.
Running time: O(n)
uncons :: forall a. List a -> Maybe { head :: a, tail :: List a }
Break a list into its first element, and the remaining elements,
or Nothing
if the list is empty.
Running time: O(1)
reverse :: forall a. List a -> List a
otherwise = go (n + 1) xs Reverse a list.
Running time: O(n)
concat :: forall a. List (List a) -> List a
Flatten a list of lists.
Running time: O(n)
, where n
is the total number of elements.
concatMap :: forall a b. (a -> List b) -> List a -> List b
Apply a function to each element in a list, and flatten the results into a single, new list.
Running time: O(n)
, where n
is the total number of elements.
filter :: forall a. (a -> Boolean) -> List a -> List a
Filter a list, keeping the elements which satisfy a predicate function.
Running time: O(n)