The prelude: types and functions available in every Aiken module, without any import. Low-level Plutus builtins live in aiken/builtin.
Types
Bool
A type for booleans values. See Primitive Types :: Bool for details.
Constructors
FalseTrueByteArray
A type for representing bytes. See Primitive Types :: ByteArray for details.
Data
A type for opaque Plutus data. See Primitive Types :: Data for details.
Fuzzer<a>
A type to capture random computation that may depend on one another. Useful for constructing (pseudo-)random values for property-based test.
Alias
Fuzzer<a> = fn(PRNG) -> Option<(PRNG, a)>G1Element
A type for representing G1 element of BLS12_381 curves.
G2Element
A type for representing G2 element of BLS12_381 curves.
Int
A type for signed integers. See Primitive Types :: Int for details.
Note: there’s no floating numbers in Aiken.
List<a>
A type for generic lists. See Primitive Types :: List for details.
MillerLoopResult
A type for representing Miller-loop results.
Never
A type that like Option but that is always None. Fundamentally, we have:
let never: Data = Never
let none: Data = None
never == noneConstructors
NeverOption<a>
A type for returning optional results. See also stdlib/option.
Constructors
Some(a)NoneOrdering
A type to compare values.
pub fn compare(left: Int, right: Int) -> Ordering {
if left < right {
Less
} else if less > right {
Greater
} else {
Equal
}
}Constructors
LessEqualGreaterPRNG
A type that represent Pseudo-random generated values.
Constructors
Seeded { seed: ByteArray, choices: ByteArray }Replayed { cursor: Int, choices: ByteArray }Pair<k, v>
An pair of 2 elements.
Pairs<k, v>
A associative list as a list of pairs of 2 elements.
Alias
Pairs<k, v> = List<Pair<k, v>>Sampler<a>
A type to capture scaled fuzzers. Useful for constructing (pseudo-)random for benchmarks from a controlled monotically increasing size.
Alias
Sampler<a> = fn(Int) -> Fuzzer<a>String
A type for text strings. See Primitive Types :: String for details.
Value
A type for builtins multi-assets values. See Primitive Types :: Value for details.
Void
A type for nullary constructors. See Primitive Types :: Void for details.
Functions
always
always(a: a, b) -> aA function that always return its first argument. Handy in folds and maps.
let always_14 = always(14, _)
always_14(42) == 14
always_14(1337) == 14
always_14(0) == 14as_data
as_data(data: Data) -> DataAn identity function to upcast any serialisable type into Data, in places where the compiler cannot implicitly infer it.
let my_uniform_list: List<Data> = [as_data(Foo(14)), as_data(Bar(True))]flip
flip(f: fn(a, b) -> c) -> fn(b, a) -> cA function that flips the arguments of a function.
pub fn titleize(left: String, right: String) {}
titleize("Hello", "World") // "Hello, World!"
flip(titleize)("Hello", "World") // "World, Hello!"identity
identity(a: a) -> aA function that returns its argument. Handy as a default behavior sometimes.
not
not(self: Bool) -> BoolLike !, but as a function. Handy for chaining using the pipe operator |> or to pass as a function.
tautology
tautology(a) -> BoolTurn any expression into a truthy statement. Useful for tests that are meant to fail but needs a predicate.