Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Scott-encoded lists and ListLike typeclass
Synopsis
- data PList (a :: S -> Type) (s :: S)
- ptryUncons :: PIsListLike list a => Term s (list a :--> PPair a (list a))
- puncons :: PIsListLike list a => Term s (list a :--> PMaybe (PPair a (list a)))
- pzip :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list (PPair a b)) => Term s (list a :--> (list b :--> list (PPair a b)))
- pfind :: PIsListLike l a => Term s ((a :--> PBool) :--> (l a :--> PMaybe a))
- preverse :: forall (l :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). PIsListLike l a => Term s (l a :--> l a)
- pcheckSorted :: forall (l :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PIsListLike l a, POrd a) => Term s (l a :--> PBool)
- pelem :: (PIsListLike list a, PEq a) => Term s (a :--> (list a :--> PBool))
- (#!!) :: PIsListLike l a => Term s (l a) -> Term s PInteger -> Term s a
- pelemAt :: PIsListLike l a => Term s (PInteger :--> (l a :--> a))
- pelemAt' :: PIsListLike l a => Term s (PInteger :--> (l a :--> a))
- plistEquals :: (PIsListLike list a, PEq a) => Term s (list a :--> (list a :--> PBool))
Documentation
data PList (a :: S -> Type) (s :: S) Source #
Instances
ptryUncons :: PIsListLike list a => Term s (list a :--> PPair a (list a)) Source #
Extract head and tail of the list, throws error if list is empty.
puncons :: PIsListLike list a => Term s (list a :--> PMaybe (PPair a (list a))) Source #
Extract head and tail of the list, if list is not empty.
pzip :: (PListLike list, PElemConstraint list a, PElemConstraint list b, PElemConstraint list (PPair a b)) => Term s (list a :--> (list b :--> list (PPair a b))) Source #
O(min(n, m)) . Zip two lists together, creating pairs of the elements.
If the lists are of differing lengths, cut to the shortest.
pfind :: PIsListLike l a => Term s ((a :--> PBool) :--> (l a :--> PMaybe a)) Source #
O(n) . like haskell level find
but on plutarch level
preverse :: forall (l :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). PIsListLike l a => Term s (l a :--> l a) Source #
O(n) . Reverse a list-like structure.
@since WIP
pcheckSorted :: forall (l :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PIsListLike l a, POrd a) => Term s (l a :--> PBool) Source #
O(n) . Checks if a list-list structure is sorted.
@since WIP
pelem :: (PIsListLike list a, PEq a) => Term s (a :--> (list a :--> PBool)) Source #
O(n) . Check if element is in the list
(#!!) :: PIsListLike l a => Term s (l a) -> Term s PInteger -> Term s a Source #
O(n) . Like Haskell level (!!)
but on the plutarch level
pelemAt :: PIsListLike l a => Term s (PInteger :--> (l a :--> a)) Source #
O(n) . Like Haskell level (!!)
but on the Plutarch level, not infix and
with arguments reversed, errors if the specified index is greater than or equal
to the lists length
pelemAt' :: PIsListLike l a => Term s (PInteger :--> (l a :--> a)) Source #
O(n) . like pelemAt
but doesn't fail on negative indexes
plistEquals :: (PIsListLike list a, PEq a) => Term s (list a :--> (list a :--> PBool)) Source #
O(min(n, m)) . Check if two lists are equal.