scalus.prelude

package scalus.prelude

Members list

Type members

Classlikes

case class AssocMap[A, B](toList: List[(A, B)])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object AssocMap

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
AssocMap.type

Validator, parametrized by Data. Keep

Validator, parametrized by Data. Keep

Needed for compatibility with solutions which use existing uplc scripts and apply Data as parameter on UPLC level.

Attributes

Supertypes
class Object
trait Matchable
class Any
@FunctionalInterface
trait Eq[-A] extends (A, A) => Boolean, CompileDerivations

Attributes

Companion
object
Supertypes
trait (A, A) => Boolean
class Object
trait Matchable
class Any
object Eq

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Eq.type
enum List[+A]

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Cons[A]
object List

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
List.type
object Math

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Math.type
enum Option[+A]

Alternative to scala.Option in onchain code.

Alternative to scala.Option in onchain code.

Options Eq and Ord are defined in terms of the contained A elements.

Type parameters

A

the type of the element contained in the Option

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Some[A]
object Option

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Option.type
@FunctionalInterface
trait Ord[-A] extends (A, A) => Order, CompileDerivations

Attributes

Companion
object
Supertypes
trait (A, A) => Order
class Object
trait Matchable
class Any
object Ord

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Ord.type
enum Order

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Order

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Order.type

Attributes

Supertypes
class Object
trait Matchable
class Any
object Prelude

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Prelude.type
case class Rational(numerator: BigInt, denominator: BigInt)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Rational

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Rational.type
@FunctionalInterface
trait Show[A] extends A => String, CompileDerivations

This is used to provide a string representation of values, which can be useful for debugging, logging, or displaying information about the value.

  • A typeclass for converting values of type A to a String.

This is used to provide a string representation of values, which can be useful for debugging, logging, or displaying information about the value.

Type parameters

A

the type of the value to be shown

Attributes

Companion
object
Supertypes
trait A => String
class Object
trait Matchable
class Any
object Show

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Show.type
@FunctionalInterface

Attributes

Companion
object
Supertypes
trait A => ByteString
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case class SortedMap[A, B]

Alternative to scala.collection.immutable.SortedMap in onchain code.

Alternative to scala.collection.immutable.SortedMap in onchain code.

Type parameters

A

the type of keys, must be an instance of Ord

B

the type of values

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SortedMap

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
SortedMap.type
class StdlibTestKit extends AnyFunSuite, ScalaCheckPropertyChecks, ArbitraryInstances

Attributes

Supertypes
trait ScalaCheckPropertyChecks
trait ScalaCheckDrivenPropertyChecks
trait Configuration
trait TableDrivenPropertyChecks
trait Tables
trait Whenever
class AnyFunSuite
trait AnyFunSuiteLike
trait Documenting
trait Alerting
trait Notifying
trait Informing
trait TestRegistration
trait TestSuite
trait Suite
trait Serializable
trait Assertions
trait TripleEquals
trait TripleEqualsSupport
class Object
trait Matchable
class Any
Show all
enum These[+A, +B]

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object These

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
These.type
trait Validator

Attributes

Supertypes
class Object
trait Matchable
class Any
case class Varargs[T](list: List[T])

Represents a variable number of arguments as a list.

Represents a variable number of arguments as a list.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

type BuiltinData = Data

Value members

Concrete methods

inline def ???: Nothing

??? can be used for marking methods that remain to be implemented.

??? can be used for marking methods that remain to be implemented.

Attributes

Throws
NotImplementedError

when ??? is invoked.

inline def fail(inline message: String): Nothing

Fails the onchain evaluation with an ERROR term and a specific error message.

Fails the onchain evaluation with an ERROR term and a specific error message.

This is used to indicate a failure in the on-chain logic with a specific error message.

Value parameters

message

The error message to include in the failure.

Attributes

Throws
OnchainError

when invoked off-chain.

inline def fail(): Nothing

Fails the onchain evaluation with an ERROR term.

Fails the onchain evaluation with an ERROR term.

This is used to indicate a failure in the on-chain logic without providing a specific error message.

Attributes

Throws
OnchainError

when invoked off-chain.

inline def identity[A](inline value: A): A
inline def impossible(): Nothing

Fails the onchain evaluation with an ERROR term indicating an impossible situation.

Fails the onchain evaluation with an ERROR term indicating an impossible situation.

This is used to indicate an impossible situation in the on-chain logic.

Attributes

Throws
ImpossibleLedgerStateError

when invoked off-chain.

inline def log(inline msg: String): Unit
inline def require(inline requirement: Boolean, inline message: String): Unit

Tests an expression, throwing an RequirementError if false.

Tests an expression, throwing an RequirementError if false.

Value parameters

requirement

the expression to test

Attributes

Throws
RequirementError

when invoked off-chain.

Note

we do not use scala.Predef.require because it's not an inline method and it's not expanded before Scalus compiler plugin phase.

Example
 require(value > 1000, "Not enough")
inline def require(inline requirement: Boolean): Unit

Tests an expression, throwing a RequirementError if false.

Tests an expression, throwing a RequirementError if false.

This is used to enforce preconditions in on-chain logic.

Value parameters

requirement

The boolean expression to test.

Attributes

Throws
RequirementError

when invoked off-chain.

Example
 require(value > 1000)

Extensions

Extensions

extension [A](self: A)
inline def also[B](inline callback: A => Unit): A
inline def let[B](inline fn: A => B): B
extension [A](self: A)(implicit evidence$1: Ord[A])
infix inline def <=>: Order
extension [A](self: A)
inline def show: String
extension [A](self: A)
extension (self: BigInt)
def to(other: BigInt): List[BigInt]
def until(other: BigInt): List[BigInt]
extension (self: BigInt.type)
def unapply(value: BigInt): Option[BigInt]
extension [A](self: Seq[A])
def asScalus: List[A]

Converts a scala.Seq to a List.

Converts a scala.Seq to a List.

This method is only available offchain.

Attributes

Returns

A List[A] containing all the elements from this sequence in the same order.

Example
 scala.Seq.empty[BigInt].asScalus === List.empty[BigInt]
 val seq: scala.Seq[BigInt] = scala.Seq(BigInt(1), BigInt(2), BigInt(3))
 seq.asScalus === Cons(BigInt(1), Cons(BigInt(2), Cons(BigInt(3), Nil)))
extension [A](self: Option[A])
def asScalus: Option[A]

Converts a scala.Option to an Option

Converts a scala.Option to an Option

Attributes

extension (self: BigInt)
inline def absolute: BigInt

Calculate the absolute value of the integer.

Calculate the absolute value of the integer.

Value parameters

other

The other number to compute ABS with.

Attributes

See also
inline def clamp(min: BigInt, max: BigInt): BigInt

Restrict the value of this integer between two bounds

Restrict the value of this integer between two bounds

Value parameters

max

highest allowed value.

min

lowest allowed value.

Attributes

See also
inline def exp2: BigInt

Calculates the power of 2 for this exponent.

Calculates the power of 2 for this exponent.

Attributes

See also
inline def gcf(other: BigInt): BigInt

The greatest common factor aka divisor of this and another integer.

The greatest common factor aka divisor of this and another integer.

Value parameters

other

The other integer to compute GCD with.

Attributes

See also
inline def isSqrt(x: BigInt): Boolean

Checks if this integer has a given integer square root x.

Checks if this integer has a given integer square root x.

Value parameters

x

square root to check.

Attributes

See also
inline def log2: BigInt

The integer logarithm in base 2.

The integer logarithm in base 2.

Attributes

See also
inline def logarithm(base: BigInt): BigInt

Computes the logarithm in a given base using integer divisions.

Computes the logarithm in a given base using integer divisions.

Value parameters

base

Base of logarithm.

Attributes

See also
inline def maximum(other: BigInt): BigInt

Returns the larger of this and another integer.

Returns the larger of this and another integer.

Value parameters

other

The other number to compute MAX with.

Attributes

See also

scalus.prelude.Math.maximum

inline def minimum(other: BigInt): BigInt

Returns the smaller of this and another integer.

Returns the smaller of this and another integer.

Value parameters

other

The other number to compute MIN with.

Attributes

See also
inline def pow(exp: BigInt): BigInt

Raises this integer to a power using the exponentiation by squaring method.

Raises this integer to a power using the exponentiation by squaring method.

Value parameters

exp

The exponent of power to raise.

Attributes

See also
inline def sqRoot: Option[BigInt]

Calculates the square root of this integer using the babylonian method.

Calculates the square root of this integer using the babylonian method.

Attributes

See also
extension [T](seq: Seq[T])
def list: List[T]
extension [A](x: A)
infix inline def !==(inline y: A)(using inline eq: Eq[A]): Boolean
infix inline def ===(inline y: A)(using inline eq: Eq[A]): Boolean

Deprecated extensions

extension (x: Boolean)
inline def ?: Boolean

Trace the expression only if it evaluates to false. This is useful to trace an entire evaluation path that led to a final expression being false.

Trace the expression only if it evaluates to false. This is useful to trace an entire evaluation path that led to a final expression being false.

Attributes

Returns

the value of the expression

Example
mustBeAfter.? && mustSpendToken.?

will trace "mustSpendToken ? False" if mustBeAfter is true and mustSpendToken is false.

infix inline def orFail(inline message: String): Unit

Attributes

Deprecated
[Since version 0.13.0] Use prelude.require() instead