plutus-core-0.1.0.0: Language library for Plutus Core
Safe HaskellNone
LanguageHaskell2010

PlutusCore.StdLib.Data.List

Description

Built-in list and related functions.

Synopsis

Documentation

list :: uni `Contains` [] => Type TyName uni () Source #

[] as a built-in PLC type.

caseList :: TermLike term TyName Name DefaultUni DefaultFun => term () Source #

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

/\(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))
        ()

foldrList :: TermLike term TyName Name DefaultUni DefaultFun => 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) ->
        caseList {a} xs {r} z \(x : a) (xs' : list a) -> f x (rec xs')

foldList :: TermLike term TyName Name DefaultUni DefaultFun => 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) ->
        caseList {a} xs {r} z \(x : a) (xs' : list a) -> rec (f z x) xs'

product :: TermLike term TyName Name DefaultUni DefaultFun => term () Source #

product as a PLC term.

foldList {integer} {integer} multiplyInteger 1