Scala data modeling
Modeling domain entities and transformations using case classes, companion objects, and type-safe hierarchies.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill scala-data-modelingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.9 KB, 183 tokens by cl100k_base, as published. Nobody here has run it
Modeling Strategies
- Case Classes: Use
case classfor immutable data structures. They provide structural equality, pattern matching support, and a concise syntax. - Companion Objects: Place factory methods, default values, and related logic in a
companion object. - ADT (Algebraic Data Types): Combine
sealed traitwithcase class/case objectfor type-safe modeling of heterogeneous data. - Type Aliases: Use
typefor simplifying complex types.
Example
sealed trait TokenValue
case class StringVal(s: String) extends TokenValue
case class NumericVal(n: Double) extends TokenValue
case class Token(value: TokenValue, metadata: Map[String, String] = Map.empty)
object Token {
def apply(s: String): Token = new Token(StringVal(s))
}
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.