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 compability with solutions which use existing uplc scripts and apply Data as parameter on UPLC level.

Attributes

Supertypes
class Object
trait Matchable
class Any
object EqCompanion

Attributes

Supertypes
class Object
trait Matchable
class Any
Self 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
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

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

Attributes

Supertypes
class Object
trait Matchable
class Any
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
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 Eq[-A] = (A, A) => Boolean

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](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(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)

Concrete fields

val Eq: EqCompanion.type

Givens

Givens

inline given given_Eq_BigInt: () => BigInt
inline given given_Eq_Boolean: () => Boolean
inline given given_Eq_ByteString: () => ByteString
inline given given_Eq_Data: () => Data
inline given given_Eq_String: () => String
inline given given_Eq_Unit: () => Unit

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 (self: BigInt)
def to(other: BigInt): List[BigInt]
def until(other: BigInt): List[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 [T](seq: Seq[T])
def list: List[T]
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
extension [A](x: A)
inline def !==(inline y: A)(using inline eq: () => A): Boolean
inline def ===(inline y: A)(using inline eq: () => A): Boolean