plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.List

Description

Scott-encoded lists and ListLike typeclass

Synopsis

Documentation

data PList (a :: S -> Type) (s :: S) Source #

Constructors

PSCons (Term s a) (Term s (PList a)) 
PSNil 

Instances

Instances details
PListLike PList Source # 
Instance details

Defined in Plutarch.List

Associated Types

type PElemConstraint PList a Source #

Methods

pelimList :: forall (a :: S -> Type) (s :: S) (r :: PType). PElemConstraint PList a => (Term s a -> Term s (PList a) -> Term s r) -> Term s r -> Term s (PList a) -> Term s r Source #

pcons :: forall (a :: S -> Type) (s :: S). PElemConstraint PList a => Term s (a :--> (PList a :--> PList a)) Source #

pnil :: forall (a :: S -> Type) (s :: S). PElemConstraint PList a => Term s (PList a) Source #

phead :: forall (a :: S -> Type) (s :: S). PElemConstraint PList a => Term s (PList a :--> a) Source #

ptail :: forall (a :: S -> Type) (s :: S). PElemConstraint PList a => Term s (PList a :--> PList a) Source #

pnull :: forall (a :: S -> Type) (s :: S). PElemConstraint PList a => Term s (PList a :--> PBool) Source #

PEq a => PEq (PList a) Source # 
Instance details

Defined in Plutarch.List

Methods

(#==) :: forall (s :: S). Term s (PList a) -> Term s (PList a) -> Term s PBool Source #

DerivePlutusType (PList a) Source # 
Instance details

Defined in Plutarch.List

Associated Types

type DPTStrat (PList a) Source #

PlutusType (PList a) Source # 
Instance details

Defined in Plutarch.List

Associated Types

type PInner (PList a) :: PType Source #

type PCovariant' (PList a) Source #

type PContravariant' (PList a) Source #

type PVariant' (PList a) Source #

Methods

pcon' :: forall (s :: S). PList a s -> Term s (PInner (PList a)) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner (PList a)) -> (PList a s -> Term s b) -> Term s b Source #

PShow a => PShow (PList a) Source # 
Instance details

Defined in Plutarch.List

Methods

pshow' :: forall (s :: S). Bool -> Term s (PList a) -> Term s PString Source #

Generic (PList a s) Source # 
Instance details

Defined in Plutarch.List

Associated Types

type Rep (PList a s) :: Type -> Type Source #

Methods

from :: PList a s -> Rep (PList a s) x Source #

to :: Rep (PList a s) x -> PList a s Source #

type PElemConstraint PList _1 Source # 
Instance details

Defined in Plutarch.List

type PElemConstraint PList _1 = ()
type DPTStrat (PList a) Source # 
Instance details

Defined in Plutarch.List

type PContravariant' (PList a) Source # 
Instance details

Defined in Plutarch.List

type PCovariant' (PList a) Source # 
Instance details

Defined in Plutarch.List

type PCovariant' (PList a) = All2 PCovariant'' (PCode (PList a))
type PInner (PList a) Source # 
Instance details

Defined in Plutarch.List

type PVariant' (PList a) Source # 
Instance details

Defined in Plutarch.List

type PVariant' (PList a) = All2 PVariant'' (PCode (PList a))
type Rep (PList a s) Source # 
Instance details

Defined in Plutarch.List

type Rep (PList a s) = D1 ('MetaData "PList" "Plutarch.List" "plutarch-1.9.0-FtN0mhIoM9oEvz7Q98pjWP" 'False) (C1 ('MetaCons "PSCons" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PList a)))) :+: C1 ('MetaCons "PSNil" 'PrefixI 'False) (U1 :: Type -> Type))

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.