Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- type PIsListLike list a = (PListLike list, PElemConstraint list a)
- class PListLike (list :: (S -> Type) -> S -> Type)
- type family PElemConstraint list (a :: S -> Type) :: Constraint
- pelimList :: (PListLike list, PElemConstraint list a) => (Term s a -> Term s (list a) -> Term s r) -> Term s r -> Term s (list a) -> Term s r
- pcons :: (PListLike list, PElemConstraint list a) => Term s (a :--> (list a :--> list a))
- pnil :: (PListLike list, PElemConstraint list a) => Term s (list a)
- phead :: (PListLike list, PElemConstraint list a) => Term s (list a :--> a)
- ptail :: (PListLike list, PElemConstraint list a) => Term s (list a :--> list a)
- pnull :: (PListLike list, PElemConstraint list a) => Term s (list a :--> PBool)
- pconvertLists :: forall f g a s. (PIsListLike f a, PIsListLike g a) => Term s (f a :--> g a)
- precList :: PIsListLike list a => (Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r) -> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
- psingleton :: PIsListLike list a => Term s (a :--> list a)
- plength :: PIsListLike list a => Term s (list a :--> PInteger)
- ptryIndex :: PIsListLike list a => Natural -> Term s (list a) -> Term s a
- pdrop :: PIsListLike list a => Natural -> Term s (list a) -> Term s (list a)
- pfoldl' :: PIsListLike list a => (forall s. Term s b -> Term s a -> Term s b) -> Term s (b :--> (list a :--> b))
- pfoldl :: PIsListLike list a => Term s ((b :--> (a :--> b)) :--> (b :--> (list a :--> b)))
- pfoldr' :: PIsListLike list a => (forall s. Term s a -> Term s b -> Term s b) -> Term s (b :--> (list a :--> b))
- pfoldr :: PIsListLike list a => Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b)))
- pfoldrLazy :: PIsListLike list a => Term s ((a :--> (PDelayed b :--> b)) :--> (b :--> (list a :--> b)))
- pall :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool))
- pany :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool))
- pmap :: (PListLike list, PElemConstraint list a, PElemConstraint list b) => Term s ((a :--> b) :--> (list a :--> list b))
- pfilter :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> list a))
- pconcat :: PIsListLike list a => Term s (list a :--> (list a :--> list a))
- pzipWith :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => Term s ((a :--> (b :--> c)) :--> (list a :--> (list b :--> list c)))
- pzipWith' :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => (Term s a -> Term s b -> Term s c) -> Term s (list a :--> (list b :--> list c))
Documentation
type PIsListLike list a = (PListLike list, PElemConstraint list a) Source #
'PIsListLike list a' constraints list
be a PListLike
with valid element type, a
.
class PListLike (list :: (S -> Type) -> S -> Type) Source #
Plutarch types that behave like lists.
Instances
type family PElemConstraint list (a :: S -> Type) :: Constraint Source #
Instances
type PElemConstraint PBuiltinList a Source # | |
Defined in Plutarch.Internal.ListLike | |
type PElemConstraint PList _1 Source # | |
Defined in Plutarch.List |
pelimList :: (PListLike list, PElemConstraint list a) => (Term s a -> Term s (list a) -> Term s r) -> Term s r -> Term s (list a) -> Term s r Source #
Canonical eliminator for list-likes.
pcons :: (PListLike list, PElemConstraint list a) => Term s (a :--> (list a :--> list a)) Source #
Cons an element onto an existing list.
phead :: (PListLike list, PElemConstraint list a) => Term s (list a :--> a) Source #
Return the first element of a list. Partial, throws an error upon encountering an empty list.
ptail :: (PListLike list, PElemConstraint list a) => Term s (list a :--> list a) Source #
Take the tail of a list, meaning drop its head. Partial, throws an error upon encountering an empty list.
pnull :: (PListLike list, PElemConstraint list a) => Term s (list a :--> PBool) Source #
O(1) . Check if a list is empty
pconvertLists :: forall f g a s. (PIsListLike f a, PIsListLike g a) => Term s (f a :--> g a) Source #
O(n) . Convert from any ListLike to any ListLike, provided both lists' element constraints are met.
precList :: PIsListLike list a => (Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r) -> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r) Source #
Like pelimList
, but with a fixpoint recursion hatch.
psingleton :: PIsListLike list a => Term s (a :--> list a) Source #
O(1) . Create a singleton list from an element
plength :: PIsListLike list a => Term s (list a :--> PInteger) Source #
O(n) . Count the number of elements in the list
ptryIndex :: PIsListLike list a => Natural -> Term s (list a) -> Term s a Source #
Index a BuiltinList, throwing an error if the index is out of bounds.
pdrop :: PIsListLike list a => Natural -> Term s (list a) -> Term s (list a) Source #
Drop the first n fields of a List.
The term will be statically generated as
repeated applications of ptail
, which will be more
efficient in many circumstances.
pfoldl' :: PIsListLike list a => (forall s. Term s b -> Term s a -> Term s b) -> Term s (b :--> (list a :--> b)) Source #
The same as pfoldl
, but with Haskell-level reduction function.
pfoldl :: PIsListLike list a => Term s ((b :--> (a :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list left-associatively.
pfoldr' :: PIsListLike list a => (forall s. Term s a -> Term s b -> Term s b) -> Term s (b :--> (list a :--> b)) Source #
The same as pfoldr'
, but with Haskell-level reduction function.
pfoldr :: PIsListLike list a => Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list right-associatively.
pfoldrLazy :: PIsListLike list a => Term s ((a :--> (PDelayed b :--> b)) :--> (b :--> (list a :--> b))) Source #
O(n) . Fold on a list right-associatively, with opportunity for short circuting.
May short circuit when given reducer function is lazy in its second argument.
pall :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool)) Source #
O(n) . Check that predicate holds for all elements in a list.
pany :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> PBool)) Source #
O(n) . Check that predicate holds for any element in a list.
pmap :: (PListLike list, PElemConstraint list a, PElemConstraint list b) => Term s ((a :--> b) :--> (list a :--> list b)) Source #
O(n) . Map a function over a list of elements
pfilter :: PIsListLike list a => Term s ((a :--> PBool) :--> (list a :--> list a)) Source #
O(n) . Filter elements from a list that don't match the predicate.
pconcat :: PIsListLike list a => Term s (list a :--> (list a :--> list a)) Source #
O(n) . Concatenate two lists
Example: > pconcat # psingleton x # psingleton y == plistLiteral [x, y]
pconcat exhibits identities with empty lists such that > forall x. pconcat # pnil # x == x > forall x. pconcat # x # pnil == x
pzipWith :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => Term s ((a :--> (b :--> c)) :--> (list a :--> (list b :--> list c))) Source #
O(min(n, m)) . Zip two lists together with a passed function.
If the lists are of differing lengths, cut to the shortest.
pzipWith' :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list c) => (Term s a -> Term s b -> Term s c) -> Term s (list a :--> (list b :--> list c)) Source #
Like pzipWith
but with Haskell-level merge function.