Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
PlutusTx.Data.List
Synopsis
- data List a
- toBuiltinList ∷ List a → BuiltinList BuiltinData
- fromBuiltinList ∷ BuiltinList BuiltinData → List a
- toSOP ∷ UnsafeFromData a ⇒ List a → [a]
- fromSOP ∷ ToData a ⇒ [a] → List a
- null ∷ List a → Bool
- append ∷ List a → List a → List a
- find ∷ UnsafeFromData a ⇒ (a → Bool) → List a → Maybe a
- findIndices ∷ UnsafeFromData a ⇒ (a → Bool) → List a → List Integer
- filter ∷ (UnsafeFromData a, ToData a) ⇒ (a → Bool) → List a → List a
- mapMaybe ∷ (UnsafeFromData a, ToData b) ⇒ (a → Maybe b) → List a → List b
- any ∷ UnsafeFromData a ⇒ (a → Bool) → List a → Bool
- all ∷ UnsafeFromData a ⇒ (a → Bool) → List a → Bool
- foldMap ∷ (UnsafeFromData a, Monoid m) ⇒ (a → m) → List a → m
- map ∷ (UnsafeFromData a, ToData b) ⇒ (a → b) → List a → List b
- length ∷ List a → Integer
- mconcat ∷ (Monoid a, UnsafeFromData a) ⇒ List a → a
- cons ∷ ToData a ⇒ a → List a → List a
- uncons ∷ UnsafeFromData a ⇒ List a → Maybe (a, List a)
- and ∷ List Bool → Bool
- or ∷ List Bool → Bool
- elem ∷ ToData a ⇒ a → List a → Bool
- notElem ∷ ToData a ⇒ a → List a → Bool
- foldr ∷ UnsafeFromData a ⇒ (a → b → b) → b → List a → b
- foldl ∷ UnsafeFromData a ⇒ (b → a → b) → b → List a → b
- concat ∷ List (List a) → List a
- concatMap ∷ UnsafeFromData a ⇒ (a → List b) → List a → List b
- listToMaybe ∷ UnsafeFromData a ⇒ List a → Maybe a
- uniqueElement ∷ UnsafeFromData a ⇒ List a → Maybe a
- (!!) ∷ UnsafeFromData a ⇒ List a → Integer → a
- revAppend ∷ List a → List a → List a
- reverse ∷ List a → List a
- replicate ∷ ToData a ⇒ Integer → a → List a
- findIndex ∷ UnsafeFromData a ⇒ (a → Bool) → List a → Maybe Integer
- unzip ∷ ∀ a b. List (a, b) → (List a, List b)
- zipWith ∷ (UnsafeFromData a, UnsafeFromData b, ToData c) ⇒ (a → b → c) → List a → List b → List c
- head ∷ ∀ a. UnsafeFromData a ⇒ List a → a
- last ∷ ∀ a. UnsafeFromData a ⇒ List a → a
- tail ∷ ∀ a. List a → List a
- take ∷ ∀ a. Integer → List a → List a
- drop ∷ ∀ a. Integer → List a → List a
- dropWhile ∷ ∀ a. UnsafeFromData a ⇒ (a → Bool) → List a → List a
- splitAt ∷ ∀ a. Integer → List a → (List a, List a)
- elemBy ∷ UnsafeFromData a ⇒ (a → a → Bool) → a → List a → Bool
- nubBy ∷ ∀ a. UnsafeFromData a ⇒ (a → a → Bool) → List a → List a
- nub ∷ (Eq a, UnsafeFromData a) ⇒ List a → List a
- partition ∷ UnsafeFromData a ⇒ (a → Bool) → List a → (List a, List a)
Documentation
A list type backed directly by Data
. It is meant to be used whenever fast
encodingdecoding tofrom Data
is needed.
Instances
Lift DefaultUni (List a) Source # | |
Defined in PlutusTx.Data.List Methods lift ∷ List a → RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) Source # | |
Monoid (List a) Source # | |
Semigroup (List a) Source # | |
Show (List a) Source # | |
Eq (List a) Source # | |
Eq (List a) Source # | |
FromData (List a) Source # | |
Defined in PlutusTx.Data.List Methods fromBuiltinData ∷ BuiltinData → Maybe (List a) Source # | |
ToData (List a) Source # | |
Defined in PlutusTx.Data.List Methods toBuiltinData ∷ List a → BuiltinData Source # | |
UnsafeFromData (List a) Source # | |
Defined in PlutusTx.Data.List Methods | |
Monoid (List a) Source # | |
Defined in PlutusTx.Data.List | |
Semigroup (List a) Source # | |
(UnsafeFromData a, Pretty a) ⇒ Pretty (List a) Source # | |
Typeable DefaultUni List Source # | |
Defined in PlutusTx.Data.List Methods typeRep ∷ Proxy List → RTCompile DefaultUni fun (Type TyName DefaultUni ()) Source # |
toSOP ∷ 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 ∷ 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
.
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
.
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
.
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
.
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
.
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
.
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
.
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 ∷ ∀ 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 ∷ ∀ 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 ∷ ∀ 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.
dropWhile ∷ ∀ 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
.
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 ∷ ∀ 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
.