Skip to content
Cinch
Packages/cinch-base/Data.List
SAMPLE API
MODULE REFERENCE

Data.List

Finite, ordered collections with structural recursion and total projections.

SYNOPSIS

Types and classes

List

data List a

A finite sequence of values of the same type.

CONSTRUCTORS

Nil :: List a

An empty list.

Cons :: a -> List a -> List a

A head element and the remaining list.

Functions and values

map

function§Source ↗
map :: forall a b. (a -> b) -> List a -> List b

Transform each element, retaining the order of the input.

EXAMPLE

map (\x -> x * 2) [1, 2, 3]
-- [2, 4, 6]

foldr

function§Source ↗
foldr :: forall a b. (a -> b -> b) -> b -> List a -> b

Fold a list from the right using a combining function and an initial value.

length

function§Source ↗
length :: forall a. List a -> Nat

Count the elements in a finite list.

EXAMPLE

length [1, 2, 3]
-- 3

head

function§Source ↗
head :: forall a. List a -> Option a

Return the first element when present. An empty list produces None.

EXAMPLE

head []
-- None

filter

function§Source ↗
filter :: forall a. (a -> Bool) -> List a -> List a

Retain elements that satisfy the predicate, in their original order.