rio-0.1.24.0: A standard library for Haskell

Safe Haskell | Safe-Inferred
Language | Haskell2010

RIO.NonEmpty.Partial

Contents

- Indexing streams
- Converting to and from a list

Description

`NonEmpty` list partial functions. Import as:

    import qualified RIO.NonEmpty.Partial as NE'

Synopsis

- (!!) :: HasCallStack => NonEmpty a -> Int -> a
- fromList :: HasCallStack => [a] -> NonEmpty a

# Indexing streams

(!!) :: HasCallStack => NonEmpty a -> Int -> a infixl 9 Source #

`xs !! n` returns the element of the stream `xs` at index `n`. Note that the head of the stream has index 0.

Beware: a negative or out-of-bounds index will cause an error.

# Converting to and from a list

fromList :: HasCallStack => [a] -> NonEmpty a Source #

Converts a normal list to a `NonEmpty` stream.

Raises an error if given an empty list.