plutus-tx-1.45.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.Data.List

Synopsis

Documentation

data List a Source #

A list type backed directly by Data. It is meant to be used whenever fast encodingdecoding tofrom Data is needed.

Instances

Instances details
Lift DefaultUni (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

lift :: List a -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) Source #

Monoid (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

mempty :: List a Source #

mappend :: List a -> List a -> List a Source #

mconcat :: [List a] -> List a Source #

Semigroup (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

(<>) :: List a -> List a -> List a Source #

sconcat :: NonEmpty (List a) -> List a Source #

stimes :: Integral b => b -> List a -> List a Source #

Show (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

showsPrec :: Int -> List a -> ShowS Source #

show :: List a -> String Source #

showList :: [List a] -> ShowS Source #

Eq (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

(==) :: List a -> List a -> Bool Source #

(/=) :: List a -> List a -> Bool Source #

Eq (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

(==) :: List a -> List a -> Bool Source #

FromData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

ToData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

UnsafeFromData (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Monoid (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

mempty :: List a Source #

Semigroup (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

(<>) :: List a -> List a -> List a Source #

(UnsafeFromData a, Pretty a) => Pretty (List a) Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

pretty :: List a -> Doc ann

prettyList :: [List a] -> Doc ann

Typeable DefaultUni List Source # 
Instance details

Defined in PlutusTx.Data.List

Methods

typeRep :: Proxy List -> RTCompile DefaultUni fun (Type TyName DefaultUni ()) Source #

caseList Source #

Arguments

:: forall a r. UnsafeFromData a 
=> (() -> r)

Nil case

-> (a -> List a -> r)

Cons case

-> List a 
-> r 

Matching on the given List.

caseList' Source #

Arguments

:: forall a r. UnsafeFromData a 
=> r

Nil case

-> (a -> List a -> r)

Cons case

-> List a 
-> r 

Like caseList, except the nil case takes an r directly, which is evaluated strictly. If r is an error or expensive computation, consider using caseList instead.

append :: List a -> List a -> List a Source #

find :: UnsafeFromData a => (a -> Bool) -> List a -> Maybe a Source #

Find the first element that satisfies a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

findIndices :: UnsafeFromData a => (a -> Bool) -> List a -> List Integer Source #

Find the indices of all elements that satisfy a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

filter :: (UnsafeFromData a, ToData a) => (a -> Bool) -> List a -> List a Source #

Filter a list using a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

mapMaybe :: (UnsafeFromData a, ToData b) => (a -> Maybe b) -> List a -> List b Source #

Map a function over a list and discard the results that are Nothing. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData, or if the result of applying f is expensive to encode to BuiltinData.

any :: UnsafeFromData a => (a -> Bool) -> List a -> Bool Source #

Check if any element in the list satisfies a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

all :: UnsafeFromData a => (a -> Bool) -> List a -> Bool Source #

Check if all elements in the list satisfy a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

foldMap :: (UnsafeFromData a, Monoid m) => (a -> m) -> List a -> m Source #

Fold a list using a monoid. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

map :: (UnsafeFromData a, ToData b) => (a -> b) -> List a -> List b Source #

Map a function over a list. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData, or if the result of applying f is expensive to encode to BuiltinData.

length :: List a -> Integer Source #

Get the length of a list.

mconcat :: (Monoid a, UnsafeFromData a) => List a -> a Source #

Concatenate a list of monoids. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

(<|) :: ToData a => a -> List a -> List a infixr 5 Source #

Prepend an element to the list.

cons :: ToData a => a -> List a -> List a Source #

Synonym for <|.

nil :: List a Source #

Construct an empty list.

singleton :: ToData a => a -> List a Source #

Create a list from a single element.

uncons :: UnsafeFromData a => List a -> Maybe (a, List a) Source #

Get the first element of a list and the rest of the list.

and :: List Bool -> Bool Source #

Check if all elements in the list are True. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

or :: List Bool -> Bool Source #

Check if any element in the list is True. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

elem :: ToData a => a -> List a -> Bool Source #

Check if an element is in the list. Note: this function can leverage the better performance of equality checks for BuiltinData.

notElem :: ToData a => a -> List a -> Bool Source #

Check if an element is not in the list.

foldr :: UnsafeFromData a => (a -> b -> b) -> b -> List a -> b Source #

Fold a list from the right. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

foldl :: UnsafeFromData a => (b -> a -> b) -> b -> List a -> b Source #

Fold a list from the left. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

concat :: List (List a) -> List a Source #

Flatten a list of lists into a single list.

concatMap :: UnsafeFromData a => (a -> List b) -> List a -> List b Source #

Map a function over a list and concatenate the results.

listToMaybe :: UnsafeFromData a => List a -> Maybe a Source #

Get the first element of a list if it is not empty.

uniqueElement :: UnsafeFromData a => List a -> Maybe a Source #

Get the element of a list if it has exactly one element.

(!!) :: UnsafeFromData a => List a -> Integer -> a infixl 9 Source #

Get the element at a given index. Warning: this is a partial function and will fail if the index is negative or greater than the length of the list. Note: this function has the same precedence as (!!) from List.

revAppend :: List a -> List a -> List a Source #

Append two lists in reverse order.

reverse :: List a -> List a Source #

Reverse a list.

replicate :: ToData a => Integer -> a -> List a Source #

Replicate a value n times.

findIndex :: UnsafeFromData a => (a -> Bool) -> List a -> Maybe Integer Source #

Find the index of the first element that satisfies a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

unzip :: forall a b. List (a, b) -> (List a, List b) Source #

Split a list of pairs into a pair of lists.

zipWith :: (UnsafeFromData a, UnsafeFromData b, ToData c) => (a -> b -> c) -> List a -> List b -> List c Source #

Zip two lists together using a function. Warning: this function can be very inefficient if the lists contain elements that are expensive to decode from BuiltinData, or if the result of applying f is expensive to encode to BuiltinData.

head :: forall a. UnsafeFromData a => List a -> a Source #

Return the head of a list. Warning: this is a partial function and will fail if the list is empty.

last :: forall a. UnsafeFromData a => List a -> a Source #

Return the last element of a list. Warning: this is a partial function and will fail if the list is empty.

tail :: forall a. List a -> List a Source #

Return the tail of a list. Warning: this is a partial function and will fail if the list is empty.

take :: forall a. Integer -> List a -> List a Source #

Take the first n elements from the list.

drop :: forall a. Integer -> List a -> List a Source #

Drop the first n elements from the list.

dropWhile :: forall a. UnsafeFromData a => (a -> Bool) -> List a -> List a Source #

Drop elements from the list while the predicate holds. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

splitAt :: forall a. Integer -> List a -> (List a, List a) Source #

Split a list at a given index.

elemBy :: UnsafeFromData a => (a -> a -> Bool) -> a -> List a -> Bool Source #

Check if an element satisfying a binary predicate is in the list. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

nubBy :: forall a. UnsafeFromData a => (a -> a -> Bool) -> List a -> List a Source #

Removes elements from the list that satisfy a binary predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

nub :: (Eq a, UnsafeFromData a) => List a -> List a Source #

Removes duplicate elements from the list. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

partition :: UnsafeFromData a => (a -> Bool) -> List a -> (List a, List a) Source #

Partition a list into two lists based on a predicate. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

toSOP :: forall a. UnsafeFromData a => List a -> [a] Source #

Convert a data-backed list to a sums of products list. Warning: this function can be very inefficient if the list contains elements that are expensive to decode from BuiltinData.

fromSOP :: forall a. ToData a => [a] -> List a Source #

Convert a sums of products list to a data-backed list. Warning: this function can be very inefficient if the list contains elements that are expensive to encode to BuiltinData.