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

PlutusCore.StdLib.Data.Function

Description

Combinators.

Synopsis

Documentation

const :: TermLike term TyName Name uni fun => term () Source #

const as a PLC term.

/\(A B :: *) -> \(x : A) (y : B) -> x

idFun :: TermLike term TyName Name uni fun => term () Source #

id as a PLC term.

/\(A :: *) -> \(x : A) -> x

applyFun :: TermLike term TyName Name uni fun => term () Source #

($) as a PLC term.

/\(A B :: *) -> \(f : A -> B) (x : A) -> f x

selfData :: RecursiveType uni fun () Source #

Self as a PLC type.

fix \(self :: * -> *) (a :: *) -> self a -> a

unroll :: TermLike term TyName Name uni fun => term () Source #

unroll as a PLC term.

/\(a :: *) -> \(s : self a) -> unwrap s s

fix :: TermLike term TyName Name uni fun => term () Source #

fix as a PLC term.

/\(a b :: *) -> \(f : (a -> b) -> a -> b) ->
    unroll {a -> b} (iwrap selfF (a -> b) \(s : self (a -> b)) ->
        f (\(x : a) -> unroll {a -> b} s x))

See plutusrunQuote $ docsfomega/z-combinator-benchmarks for details.

fixAndType :: TermLike term TyName Name uni fun => (term (), Type TyName uni ()) Source #

fixBy :: TermLike term TyName Name uni fun => term () Source #

The fixBy combinator.

fixBy :
    forall (F :: * -> *) .
    ((F ~> Id) -> (F ~> Id)) ->
    ((F ~> F) -> (F ~> Id))

fixByAndType :: TermLike term TyName Name uni fun => (term (), Type TyName uni ()) Source #

fixN :: TermLike term TyName Name uni fun => Integer -> term () -> term () Source #

Make a n-ary fixpoint combinator.

FixN n :
    forall A1 B1 ... An Bn :: * .
    (forall Q :: * .
        ((A1 -> B1) -> ... -> (An -> Bn) -> Q) ->
        (A1 -> B1) ->
        ... ->
        (An -> Bn) ->
        Q) ->
    (forall R :: * . ((A1 -> B1) -> ... (An -> Bn) -> R) -> R)

fixNAndType :: TermLike term TyName Name uni fun => Integer -> term () -> (term (), Type TyName uni ()) Source #

data FunctionDef term tyname name uni fun ann Source #

A PLC function.

Constructors

FunctionDef 

Fields

getMutualFixOf :: TermLike term TyName Name uni fun => ann -> term ann -> [FunctionDef term TyName Name uni fun ann] -> Quote (Tuple term uni ann) Source #

Get the fixed-point of a list of mutually recursive functions.

MutualFixOf _ fixN [ FunctionDef _ fN1 (FunctionType _ a1 b1) f1
                   , ...
                   , FunctionDef _ fNn (FunctionType _ an bn) fn
                   ] =
    Tuple [(a1 -> b1) ... (an -> bn)] $
        fixN {a1} {b1} ... {an} {bn}
            /\(q :: *) -> \(choose : (a1 -> b1) -> ... -> (an -> bn) -> q) ->
                \(fN1 : a1 -> b1) ... (fNn : an -> bn) -> choose f1 ... fn

getSingleFixOf :: TermLike term TyName Name uni fun => ann -> term ann -> FunctionDef term TyName Name uni fun ann -> term ann Source #

Get the fixed-point of a single recursive function.