plutus-core-1.39.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.StdLib.Data.List

Description

Built-in list and related functions.

Synopsis

Documentation

list ∷ uni `HasTypeLevel` ListType tyname uni () Source #

[] as a built-in PLC type.

data MatchOption Source #

Allows one to choose which way of doing pattern matching on built-in types to use: either via ChooseList-like builtins or via CaseList-like ones.

Constructors

UseChoose 
UseCase 

matchListTermLike term TyName Name DefaultUni DefaultFunMatchOption → term () Source #

Pattern matching on built-in lists. matchList {a} xs on built-in lists is equivalent to unwrap xs on lists defined in PLC itself (hence why we bind r after xs).

Either

/\(a :: *) -> \(xs : list a) -> /\(r :: *) -> (z : r) (f : a -> list a -> r) ->
    matchList
        {a}
        {r}
        z
        f
        xs

or

/\(a :: *) -> \(xs : list a) -> /\(r :: *) -> (z : r) (f : a -> list a -> r) ->
    chooseList
        {a}
        {() -> r}
        xs
        (\(u : ()) -> z)
        (\(u : ()) -> f (head {a} xs) (tail {a} xs))
        ()

depending on the MatchOption argument.

foldrListTermLike term TyName Name DefaultUni DefaultFunMatchOption → term () Source #

foldr over built-in lists.

/\(a :: *) (r :: *) -> \(f : a -> r -> r) (z : r) ->
    fix {list a} {r} \(rec : list a -> r) (xs : list a) ->
        matchList {a} xs {r} z \(x : a) (xs' : list a) -> f x (rec xs')

foldListTermLike term TyName Name DefaultUni DefaultFunMatchOption → term () Source #

'foldl'' as a PLC term.

/\(a :: *) (r :: *) -> \(f : r -> a -> r) ->
    fix {r} {list a -> r} \(rec : r -> list a -> r) (z : r) (xs : list a) ->
        matchList {a} xs {r} z \(x : a) (xs' : list a) -> rec (f z x) xs'

productTermLike term TyName Name DefaultUni DefaultFunMatchOption → term () Source #

product as a PLC term.

foldList {integer} {integer} multiplyInteger 1