ral-0.1: Random access lists
Safe Haskell Safe-Inferred
Language Haskell2010

Data.RAList

Description

Random access list.

This module is designed to imported qualifed.

Synopsis

Documentation

data RAList a Source #

Random access list.

Instances

Instances details
Functor RAList Source #
Instance details

Defined in Data.RAList.Internal

Foldable RAList Source #
>>> I.length $ fromList $ ['a' .. 'z']
26
Instance details

Defined in Data.RAList.Internal

Traversable RAList Source #
Instance details

Defined in Data.RAList.Internal

Arbitrary1 RAList Source #
Instance details

Defined in Data.RAList.Internal

Eq a => Eq ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Ord a => Ord ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Show a => Show ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Semigroup ( RAList a) Source #
>>> fromList "abc" <> fromList "xyz"
fromList "abcxyz"
Instance details

Defined in Data.RAList.Internal

Monoid ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Function a => Function ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Arbitrary a => Arbitrary ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

CoArbitrary a => CoArbitrary ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

NFData a => NFData ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Methods

rnf :: RAList a -> () Source #

Hashable a => Hashable ( RAList a) Source #
Instance details

Defined in Data.RAList.Internal

Showing

Construction

empty :: RAList a Source #

Empty RAList .

>>> empty :: RAList Int
fromList []

cons :: a -> RAList a -> RAList a Source #

cons for non-empty rals.

Indexing

(!?) :: RAList a -> Int -> Maybe a Source #

safe list index.

>>> fromList ['a'..'f'] !? 0
Just 'a'
>>> fromList ['a'..'f'] !? 5
Just 'f'
>>> fromList ['a'..'f'] !? 6
Nothing

uncons :: RAList a -> Maybe (a, RAList a) Source #

>>> uncons $ fromList []
Nothing
>>> uncons $ fromList "abcdef"
Just ('a',fromList "bcdef")

Conversions

fromList :: [a] -> RAList a Source #

>>> fromList ['a' .. 'f']
fromList "abcdef"
>>> explicitShow $ fromList ['a' .. 'f']
"NonEmpty (NE (Cons0 (Cons1 (Nd (Lf 'a') (Lf 'b')) (Last (Nd (Nd (Lf 'c') (Lf 'd')) (Nd (Lf 'e') (Lf 'f')))))))"

Folding

Mapping

adjust :: forall a. Int -> (a -> a) -> RAList a -> RAList a Source #

Adjust a value in the list.

>>> adjust 3 toUpper $ fromList "bcdef"
fromList "bcdEf"

If index is out of bounds, the list is returned unmodified.

>>> adjust 10 toUpper $ fromList "bcdef"
fromList "bcdef"
>>> adjust (-1) toUpper $ fromList "bcdef"
fromList "bcdef"

map :: (a -> b) -> RAList a -> RAList b Source #

>>> map toUpper (fromList ['a'..'f'])
fromList "ABCDEF"

imap :: ( Int -> a -> b) -> RAList a -> RAList b Source #

>>> imap (,) $ fromList ['a' .. 'f']
fromList [(0,'a'),(1,'b'),(2,'c'),(3,'d'),(4,'e'),(5,'f')]

itraverse :: forall f a b. Applicative f => ( Int -> a -> f b) -> RAList a -> f ( RAList b) Source #