nw-fp-scala

Solid

Scala 3 language-specific patterns with ZIO, Cats Effect, and opaque types

AI & Automation 526 stars 55 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
91
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

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
3 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category