nw-fp-scala
FeaturedScala 3 language-specific patterns with ZIO, Cats Effect, and opaque types
AI & Automation 636 stars
68 forks Updated today MIT
Install
Quality Score: 98/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# FP in Scala 3 -- Functional Software Crafter Skill
Cross-references: [fp-principles](../nw-fp-principles/SKILL.md) | [fp-domain-modeling](../nw-fp-domain-modeling/SKILL.md) | [pbt-jvm](../nw-pbt-jvm/SKILL.md)
## When to Choose Scala
- Best for: JVM with full FP power | large-scale systems | data engineering | richest effect ecosystem
- Not ideal for: small teams wanting simplicity | Android (use Kotlin) | teams allergic to OO/FP duality
## [STARTER] Quick Setup
```bash
cs install scala3-compiler scala3-repl sbt
sbt new scala/scala3.g8 && cd order-service
# Add zio, zio-test, scalacheck to build.sbt
sbt compile && sbt test
```
## [STARTER] Type System for Domain Modeling
### Choice Types and Record Types
```scala
enum PaymentMethod:
case CreditCard(cardNumber: String, expiryDate: String)
case BankTransfer(accountNumber: String)
case Cash
case class Customer(
customerId: CustomerId,
customerName: CustomerName,
customerEmail: EmailAddress
)
```
Case classes provide structural equality, copy, and pattern matching for free.
### [STARTER] Domain Wrappers (Opaque Types) -- Zero Cost
```scala
object OrderDomain:
opaque type OrderId = Int
object OrderId:
def apply(value: Int): OrderId = value
extension (id: OrderId) def value: Int = id
opaque type EmailAddress = String
object EmailAddress:
def from(raw: String): Either[ValidationError, EmailAddress] =
if raw.contains("@") then Right(raw)
else Left(InvalidEmail(raw))
```
Inside ...
Details
- Author
- nWave-ai
- Repository
- nWave-ai/nWave
- Created
- 9 months ago
- Last Updated
- today
- Language
- Python
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Featured
nw-fp-haskell
Haskell language-specific patterns, GADTs, type classes, and effect systems
636 Updated today
nWave-ai AI & Automation Featured
nw-fp-fsharp
F# language-specific patterns, Railway-Oriented Programming, and Computation Expressions
636 Updated today
nWave-ai AI & Automation Featured
nw-fp-kotlin
Kotlin language-specific patterns with Arrow, Raise DSL, and coroutine-based effects
636 Updated today
nWave-ai