Skip to Content
Scalus Club is now open! Join us to get an early access to new features 🎉
DocumentationLanguage GuideSupported Features

Supported Scala Features

Scalus compiles Scala code to Untyped Plutus Core (UPLC), a minimalist lambda calculus designed for secure blockchain execution. This constraint means only a subset of Scala’s feature set is supported—those that can be efficiently and deterministically translated to UPLC.

The compilation process transforms your Scala code into an intermediate representation before generating the final UPLC that runs on Cardano. UPLC’s deliberately limited nature (optimized for security and determinism) excludes many high-level language features.

Supported Features

Below is a comprehensive list of what Scala features are currently supported in Scalus:

  • simple vals and defs of supported built-in types or case classes/enums
  • lambda expressions
  • recursive functions
  • passing/returning functions as arguments (higher-order functions)
  • if-then-else expressions
  • simple match expressions on case classes and enums
    • only simple bindings are supported like case Costr(field, other) => ...
  • given arguments and using clauses
  • throw expressions but no try-catch expressions
  • built-in functions and operators
  • simple data types: case classes and enums
  • inline vals, functions and macros in general
  • implicit conversions
  • opaque types (non top-level) and type aliases
  • extension methods
  • tuples
  • value destructuring in vals: val Some((a, b)) = optionOfTuple

Unsupported Features

  • vars and lazy vals - use immutable val declarations instead
  • while loops - use recursion or higher-order functions like fold
  • classes, inheritance and polymorphism aka virtual dispatch
    • you can’t use isInstanceOf or runtime type checks
    • use sealed traits with enums or case classes for polymorphic data
  • pattern matching with guards - move guard conditions to the right-hand side with if-then-else
  • pattern matching on multiple constructors (case A | B => ...) - use separate cases
  • pattern matching using type ascriptions (case x: BigInt => ...) - pattern match on structure instead
  • try-catch expressions - use Option, Either, or error handling patterns instead
  • overloaded functions - each function must have a unique name
  • mutually recursive functions - functions cannot call each other recursively
Last updated on