Scala 3.4+ Development Specialist
Functional programming, effect systems, and big data processing for JVM applications.
Quick Reference
Auto-Triggers: Scala files (.scala, .sc), build files (build.sbt, project/build.properties)
Core Capabilities:
- Scala 3.4: Given/using, extension methods, enums, opaque types, match types
- Akka 2.9: Typed actors, streams, clustering, persistence
- Cats Effect 3.5: Pure FP runtime, fibers, concurrent structures
- ZIO 2.1: Effect system, layers, streaming, error handling
- Apache Spark 3.5: DataFrame API, SQL, structured streaming
Key Ecosystem Libraries:
- HTTP: Http4s 0.24, Tapir 1.10
- JSON: Circe 0.15, ZIO JSON 0.6
- Database: Doobie 1.0, Slick 3.5, Quill 4.8
- Streaming: FS2 3.10, ZIO Streams 2.1
- Testing: ScalaTest, Specs2, MUnit, Weaver
Module Index
This skill uses progressive disclosure with specialized modules:
Core Language
- functional-programming.md - Scala 3.4 features: Given/Using, Type Classes, Enums, Opaque Types, Extension Methods
Effect Systems
- cats-effect.md - Cats Effect 3.5: IO monad, Resources, Fibers, FS2 Streaming
- zio-patterns.md - ZIO 2.1: Effects, Layers, ZIO Streams, Error handling
Frameworks
- akka-actors.md - Akka Typed Actors 2.9: Actors, Streams, Clustering patterns
- spark-data.md - Apache Spark 3.5: DataFrame API, SQL, Structured Streaming
Implementation Guide
Project Setup (SBT 1.10)
ThisBuild / scalaVersion := "3.4.2"
ThisBuild / organization := "com.example"
lazy val root = (project in file("."))
.settings(
name := "scala-service",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.5.4",
"dev.zio" %% "zio" % "2.1.0",
"com.typesafe.akka" %% "akka-actor-typed" % "2.9.0",
"org.http4s" %% "http4s-ember-server" % "0.24.0",
"io.circe" %% "circe-generic" % "0.15.0",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
),
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
)
Quick Examples
Extension Methods:
extension (s: String)
def words: List[String] = s.split("\\s+").toList
def truncate(maxLen: Int): String =
if s.length <= maxLen then s else s.take(maxLen - 3) + "..."
Given and Using:
trait JsonEncoder[A]:
def encode(value: A): String
given JsonEncoder[String] with
def encode(value: String): String = s"\"$value\""
def toJson[A](value: A)(using encoder: JsonEncoder[A]): String =
encoder.encode(value)
Enum Types:
enum Result[+E, +A]:
case Success(value: A)
case Failure(error: E)
def map[B](f: A => B): Result[E, B] = this match
case Success(a) => Success(f(a))
case Failure(e) => Failure(e)
Context7 Integration
Library mappings for latest documentation:
Core Scala:
- /scala/scala3 - Scala 3.4 language reference
- /scala/scala-library - Standard library
Effect Systems:
- /typelevel/cats-effect - Cats Effect 3.5 documentation
- /typelevel/cats - Cats 2.10 functional abstractions
- /zio/zio - ZIO 2.1 documentation
- /zio/zio-streams - ZIO Streams 2.1
Akka Ecosystem:
- /akka/akka - Akka 2.9 typed actors and streams
- /akka/akka-http - Akka HTTP REST APIs
- /akka/alpakka - Akka connectors
HTTP and Web:
- /http4s/http4s - Functional HTTP server/client
- /softwaremill/tapir - API-first design
Big Data:
- /apache/spark - Spark 3.5 DataFrame and SQL
- /apache/flink - Flink 1.19 streaming
- /apache/kafka - Kafka clients 3.7
Testing Quick Reference
ScalaTest:
class UserServiceSpec extends AnyFlatSpec with Matchers:
"UserService" should "create user successfully" in {
val result = service.createUser(CreateUserRequest("John", "john@example.com"))
result.name shouldBe "John"
}
MUnit with Cats Effect:
class UserServiceSuite extends CatsEffectSuite:
test("should fetch user") {
UserService.findById(1L).map { result =>
assertEquals(result.name, "John")
}
}
ZIO Test:
object UserServiceSpec extends ZIOSpecDefault:
def spec = suite("UserService")(
test("should find user") {
for result <- UserService.findById(1L)
yield assertTrue(result.name == "John")
}
)
Troubleshooting
Common Issues:
- Implicit resolution: Use scalac -explain for detailed error messages
- Type inference: Add explicit type annotations when inference fails
- SBT slow compilation: Enable Global / concurrentRestrictions in build.sbt
Effect System Issues:
- Cats Effect: Check for missing import cats.effect.* or import cats.syntax.all.*
- ZIO: Verify layer composition with ZIO.serviceWith and ZIO.serviceWithZIO
- Akka: Review actor hierarchy and supervision strategies
Works Well With
- moai-lang-java - JVM interoperability, Spring Boot integration
- moai-domain-backend - REST API, GraphQL, microservices patterns
- moai-domain-database - Doobie, Slick, database patterns
- moai-workflow-testing - ScalaTest, MUnit, property-based testing
Additional Resources
For comprehensive reference materials:
- reference.md - Complete Scala 3.4 coverage, Context7 mappings, performance
- examples.md - Production-ready code: Http4s, Akka, Spark patterns
Last Updated: 2026-01-06
Status: Production Ready (v2.0.0)
1---2name: moai-lang-scala-33description: Scala 3.4+ development specialist covering Akka, Cats Effect, ZIO, and Spark patterns. Use when building distributed systems, big data pipelines, or functional programming applications.4---5
6# Scala 3.4+ Development Specialist
7
8Functional programming, effect systems, and big data processing for JVM applications.
9
10## Quick Reference
11
12Auto-Triggers: Scala files (.scala, .sc), build files (build.sbt, project/build.properties)
13
14Core Capabilities:
15- Scala 3.4: Given/using, extension methods, enums, opaque types, match types
16- Akka 2.9: Typed actors, streams, clustering, persistence
17- Cats Effect 3.5: Pure FP runtime, fibers, concurrent structures
18- ZIO 2.1: Effect system, layers, streaming, error handling
19- Apache Spark 3.5: DataFrame API, SQL, structured streaming
20
21Key Ecosystem Libraries:
22- HTTP: Http4s 0.24, Tapir 1.10
23- JSON: Circe 0.15, ZIO JSON 0.6
24- Database: Doobie 1.0, Slick 3.5, Quill 4.8
25- Streaming: FS2 3.10, ZIO Streams 2.1
26- Testing: ScalaTest, Specs2, MUnit, Weaver
27
28---
29
30## Module Index
31
32This skill uses progressive disclosure with specialized modules:
33
34### Core Language
35- [functional-programming.md](modules/functional-programming.md) - Scala 3.4 features: Given/Using, Type Classes, Enums, Opaque Types, Extension Methods
36
37### Effect Systems
38- [cats-effect.md](modules/cats-effect.md) - Cats Effect 3.5: IO monad, Resources, Fibers, FS2 Streaming
39- [zio-patterns.md](modules/zio-patterns.md) - ZIO 2.1: Effects, Layers, ZIO Streams, Error handling
40
41### Frameworks
42- [akka-actors.md](modules/akka-actors.md) - Akka Typed Actors 2.9: Actors, Streams, Clustering patterns
43- [spark-data.md](modules/spark-data.md) - Apache Spark 3.5: DataFrame API, SQL, Structured Streaming
44
45---
46
47## Implementation Guide
48
49### Project Setup (SBT 1.10)
50
51```scala
52ThisBuild / scalaVersion := "3.4.2"
53ThisBuild / organization := "com.example"
54
55lazy val root = (project in file("."))
56 .settings(
57 name := "scala-service",
58 libraryDependencies ++= Seq(
59 "org.typelevel" %% "cats-effect" % "3.5.4",
60 "dev.zio" %% "zio" % "2.1.0",
61 "com.typesafe.akka" %% "akka-actor-typed" % "2.9.0",
62 "org.http4s" %% "http4s-ember-server" % "0.24.0",
63 "io.circe" %% "circe-generic" % "0.15.0",
64 "org.scalatest" %% "scalatest" % "3.2.18" % Test
65 ),
66 scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
67 )
68```
69
70### Quick Examples
71
72Extension Methods:
73```scala
74extension (s: String)
75 def words: List[String] = s.split("\\s+").toList
76 def truncate(maxLen: Int): String =
77 if s.length <= maxLen then s else s.take(maxLen - 3) + "..."
78```
79
80Given and Using:
81```scala
82trait JsonEncoder[A]:
83 def encode(value: A): String
84
85given JsonEncoder[String] with
86 def encode(value: String): String = s"\"$value\""
87
88def toJson[A](value: A)(using encoder: JsonEncoder[A]): String =
89 encoder.encode(value)
90```
91
92Enum Types:
93```scala
94enum Result[+E, +A]:
95 case Success(value: A)
96 case Failure(error: E)
97
98 def map[B](f: A => B): Result[E, B] = this match
99 case Success(a) => Success(f(a))
100 case Failure(e) => Failure(e)
101```
102
103---
104
105## Context7 Integration
106
107Library mappings for latest documentation:
108
109Core Scala:
110- /scala/scala3 - Scala 3.4 language reference
111- /scala/scala-library - Standard library
112
113Effect Systems:
114- /typelevel/cats-effect - Cats Effect 3.5 documentation
115- /typelevel/cats - Cats 2.10 functional abstractions
116- /zio/zio - ZIO 2.1 documentation
117- /zio/zio-streams - ZIO Streams 2.1
118
119Akka Ecosystem:
120- /akka/akka - Akka 2.9 typed actors and streams
121- /akka/akka-http - Akka HTTP REST APIs
122- /akka/alpakka - Akka connectors
123
124HTTP and Web:
125- /http4s/http4s - Functional HTTP server/client
126- /softwaremill/tapir - API-first design
127
128Big Data:
129- /apache/spark - Spark 3.5 DataFrame and SQL
130- /apache/flink - Flink 1.19 streaming
131- /apache/kafka - Kafka clients 3.7
132
133---
134
135## Testing Quick Reference
136
137ScalaTest:
138```scala
139class UserServiceSpec extends AnyFlatSpec with Matchers:
140 "UserService" should "create user successfully" in {
141 val result = service.createUser(CreateUserRequest("John", "john@example.com"))
142 result.name shouldBe "John"
143 }
144```
145
146MUnit with Cats Effect:
147```scala
148class UserServiceSuite extends CatsEffectSuite:
149 test("should fetch user") {
150 UserService.findById(1L).map { result =>
151 assertEquals(result.name, "John")
152 }
153 }
154```
155
156ZIO Test:
157```scala
158object UserServiceSpec extends ZIOSpecDefault:
159 def spec = suite("UserService")(
160 test("should find user") {
161 for result <- UserService.findById(1L)
162 yield assertTrue(result.name == "John")
163 }
164 )
165```
166
167---
168
169## Troubleshooting
170
171Common Issues:
172- Implicit resolution: Use scalac -explain for detailed error messages
173- Type inference: Add explicit type annotations when inference fails
174- SBT slow compilation: Enable Global / concurrentRestrictions in build.sbt
175
176Effect System Issues:
177- Cats Effect: Check for missing import cats.effect.* or import cats.syntax.all.*
178- ZIO: Verify layer composition with ZIO.serviceWith and ZIO.serviceWithZIO
179- Akka: Review actor hierarchy and supervision strategies
180
181---
182
183## Works Well With
184
185- moai-lang-java - JVM interoperability, Spring Boot integration
186- moai-domain-backend - REST API, GraphQL, microservices patterns
187- moai-domain-database - Doobie, Slick, database patterns
188- moai-workflow-testing - ScalaTest, MUnit, property-based testing
189
190---
191
192## Additional Resources
193
194For comprehensive reference materials:
195- [reference.md](reference.md) - Complete Scala 3.4 coverage, Context7 mappings, performance
196- [examples.md](examples.md) - Production-ready code: Http4s, Akka, Spark patterns
197
198---
199
200Last Updated: 2026-01-06
201Status: Production Ready (v2.0.0)