Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πΊπ¦Help our brave mates in Ukraine with a donation.

## List

### `bind`

Lifts a block/proc and runs it against each member of the list. The block must return a value coercible to a list. As in other monads if no block given the first argument will be treated as callable and used instead.

``````require 'dry/monads/list'

M::List[1, 2].bind { |x| [x + 1] } # => List[2, 3]
M::List[1, 2].bind(-> x { [x, x + 1] }) # => List[1, 2, 2, 3]

M::List[1, nil].bind { |x| [x + 1] } # => error
``````

### `fmap`

Maps a block over the list. Acts as `Array#map`. As in other monads, if no block given the first argument will be treated as callable and used instead.

``````require 'dry/monads/list'

M::List[1, 2].fmap { |x| x + 1 } # => List[2, 3]
``````

### `value`

You always can unwrap the result by calling `value`.

``````require 'dry/monads/list'

M::List[1, 2].value # => [1, 2]
``````

### Concatenation

``````require 'dry/monads/list'

M::List[1, 2] + M::List[3, 4] # => List[1, 2, 3, 4]
``````

### `head` and `tail`

`head` returns the first element wrapped with a `Maybe`.

``````require 'dry/monads/list'

M::List[1, 2, 3, 4].head # => Some(1)
M::List[1, 2, 3, 4].tail # => List[2, 3, 4]
``````

### `traverse`

Traverses the list with a block (or without it). This method "flips" List structure with the given monad (obtained from the type).

Note that traversing requires the list to be typed.

``````require 'dry/monads/list'