Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Built-in list
and related functions.
Synopsis
- list ∷ uni `HasTypeLevel` List ⇒ Type tyname uni ()
- data MatchOption
- matchList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
- foldrList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
- foldList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
- sum ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
- sumr ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
- product ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term ()
Documentation
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.
Instances
Bounded MatchOption Source # | |
Defined in PlutusCore.StdLib.Data.MatchOption | |
Enum MatchOption Source # | |
Defined in PlutusCore.StdLib.Data.MatchOption succ ∷ MatchOption → MatchOption Source # pred ∷ MatchOption → MatchOption Source # toEnum ∷ Int → MatchOption Source # fromEnum ∷ MatchOption → Int Source # enumFrom ∷ MatchOption → [MatchOption] Source # enumFromThen ∷ MatchOption → MatchOption → [MatchOption] Source # enumFromTo ∷ MatchOption → MatchOption → [MatchOption] Source # enumFromThenTo ∷ MatchOption → MatchOption → MatchOption → [MatchOption] Source # | |
Show MatchOption Source # | |
Defined in PlutusCore.StdLib.Data.MatchOption | |
Eq MatchOption Source # | |
Defined in PlutusCore.StdLib.Data.MatchOption (==) ∷ MatchOption → MatchOption → Bool Source # (/=) ∷ MatchOption → MatchOption → Bool Source # |
matchList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → 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.
foldrList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → 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')
foldList ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → 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'
sum ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term () Source #
sumr ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term () Source #
product ∷ TermLike term TyName Name DefaultUni DefaultFun ⇒ MatchOption → term () Source #
product
as a PLC term.
foldList {integer} {integer} multiplyInteger 1