Skip to the content.

In this project, you will see some algebraic data types that are not implemented using the enum keyword we studied previously. For instance, the definition of Value in Interpreter.scala, or the AST definition in the src/amyc/ast/TreeModule.scala file.

Do not be intimidated! These are in fact equivalent ways of defining algebraic data types. In fact, the enum keyword desugars, at compile-time, into its implementation in terms of a sealed base class or trait and several case classes.

For more details and explanations, see the Desugaring Enumerations section in the Algebraic Data Types section of the Scala 3 book.