scala-option-either
Translating Python's None/Optional to Scala's Option, Either, and Try types
Skill by cxcscmu
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/cxcscmu-scala-option-either
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/scala-option-either
What's inside
- Skill name
scala-option-either- Description
- Translating Python's None/Optional to Scala's Option, Either, and Try types
- License
- MIT
- Instructions
- 252 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Scala Option, Either, and Try for Python Developers
## Core Concept: Functional Error Handling
Python uses `None` and `Optional[T]` to represent absence. Scala uses types that can be pattern-matched:
| Python | Scala | Purpose |
|--------|-------|---------|
| `None` | `None` (in Option) | Represents absence |
| `Optional[T]` / `T \| None` | `Option[T]` | Represents presence or absence |
| Exception handling | `Either[Err, Success]` | Represents error or success |
| Exception handling | `Try[T]` | Like Either but for exceptions |
## Option[T] - Replace None/Optional
### Python Pattern
```python
def safe_divide(a: float, b: float) -> float | None:
if b == 0:
return None
return a / b
result = safe_divide(10, 2)
if result is not None:
print(f"Result: {result}")
else:
print("Division by zero")
```
### Scala Pattern
```scala
def safeDivide(a: Double, b: Double): Option[Double] =
if (b == 0) None else Some(a / b)
// Pattern matching
safeDivide(10, 2) match {
case Some(result) => println(s"Result: $result")
case None => println("Division by zero")
}
// Or functional style
safeDivide(10, 2).foreach(result => println(s"Result: $result"))
```
### Key Option Methods
```scala
val opt: Option[Int] = Some(42)
// Extraction
opt.get // 42 (throws if None - avoid!)
opt.getOrElse(0) // 42
opt.orElse(Some(0)) // Some(42)
// Transformation
opt.map(_ * 2) // Some(84)
opt.flatMap(x => Some(x * 2)) // Some(84)
opt.filter(_ > 40) // Some(42)
// Iteration
for (v <- opt) println(v) // prints 42
// Checking
opt.isDefined // true
opt.isEmpty // false
```
## Either[L, R] - Represent Success or Failure
Either is more powerful than Option - it carries error information.
### Python Pattern
```python
def validate_age(age: int) -> tuple[bool, str | None]:
if age < 0:
return False, "Age cannot be negative"
if age > 150:
return False, "Age seems unrealistic"
return True, None
success, error = validate_age(-5)
if not success:
print(f"Error: {error}")
```
### Scala Pattern
```scala
def validateAge(age: Int): Either[String, Int] =
if (age < 0) Left("Age cannot be negative")
else if (age > 150) Left("Age seems unrealistic")
else Right(age)
// Pattern matching
validateAge(-5) match {
case Left(error) => println(s"Error: $error")
case Right(age) => println(s"Valid age: $age")
}
// Functional style
validateAge(25).map(age => age + 1).foreach(println)
```
### Either is Right-biased (map operates on Right)
```scala
val result: Either[String, Int] = Right(5)
result.map(_ * 2) // Right(10)
result.flatMap(x => Right(x * 2)) // Right(10)
result.leftMap(s => s.toUpperCase) // Left side transformation
result.fold(
error => println(s"Error: $error"), // Left side
value => println(s"Success: $value") // Right side
)
```
## Try[T] - For Exception Handling
Try captures exceptions instead of throwing them.From cxcscmu/SkillLearnBench, MIT.
More from cxcscmu/SkillLearnBench
- 0.523score
skill-creator
cxcscmu
Create modular skill documents (SKILL.md files) for Claude Code.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
package-lock-parsing
cxcscmu
Parse and extract package information from npm package-lock.json files to identify dependencies and their installed versions.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
mandarin-rhyming-guide
cxcscmu
Master modern Mandarin pinyin finals and tone systems to create accurate rhymes for classical poetry following contemporary pronunciation standards.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
trivy-vulnerability-scanning
cxcscmu
Use Trivy vulnerability scanner in offline mode to detect CVEs in npm dependencies and generate structured JSON reports.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
cvss-score-extraction
cxcscmu
Extract and handle CVSS scores from multiple vulnerability data sources (NVD, GHSA, RedHat) with proper fallback priority.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
github-metrics-processing
cxcscmu
Process GitHub API data to calculate PR/issue metrics including merge time averages, author rankings, and bug categorization.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
security-audit-csv-reporting
cxcscmu
Generate structured CSV security audit reports from vulnerability data with proper filtering, formatting, and field mapping.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
classical-poetry-peace-theme
cxcscmu
Compose classical Chinese poetry on peace themes using authentic imagery, perspective shifts, and the voice of ordinary people experiencing war's aftermath.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
seven-char-regulated-verse
cxcscmu
Master the structure, tonal patterns, and rhyming requirements of classical seven-character regulated verse (七言律诗) in Chinese poetry.
SkillDFreshness: D★ 91Claude Code +9 - 0.512score
jackson-deserialization-validation
cxcscmu
Securing Jackson JSON deserialization by validating input before processing and preventing unknown properties.
SkillDFreshness: D★ 91Claude Code +9 - 0.512score
python-pillow-graphics
cxcscmu
Create technical graphics, diagrams, and posters using Python Pillow library with precise color control and typography.
SkillDFreshness: D★ 91Claude Code +9 - 0.512score
git-patch-workflow
cxcscmu
Creating, managing, and applying unified diff patches with Git for source code modifications.
SkillDFreshness: D★ 91Claude Code +9
Signals
- Stars
- 91
- Forks
- 7
- Open issues
- 6
- Last commit (this folder)
- Apr 24, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/cxcscmu/SkillLearnBench
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from cxcscmu
- 0.523score
skill-creator
cxcscmu
Create modular skill documents (SKILL.md files) for Claude Code.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
seven-char-regulated-verse
cxcscmu
Master the structure, tonal patterns, and rhyming requirements of classical seven-character regulated verse (七言律诗) in Chinese poetry.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
security-audit-csv-reporting
cxcscmu
Generate structured CSV security audit reports from vulnerability data with proper filtering, formatting, and field mapping.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
classical-poetry-peace-theme
cxcscmu
Compose classical Chinese poetry on peace themes using authentic imagery, perspective shifts, and the voice of ordinary people experiencing war's aftermath.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
cvss-score-extraction
cxcscmu
Extract and handle CVSS scores from multiple vulnerability data sources (NVD, GHSA, RedHat) with proper fallback priority.
SkillDFreshness: D★ 91Claude Code +9 - 0.515score
mandarin-rhyming-guide
cxcscmu
Master modern Mandarin pinyin finals and tone systems to create accurate rhymes for classical poetry following contemporary pronunciation standards.
SkillDFreshness: D★ 91Claude Code +9
Cite this page
scala-option-either skill. Agent Mart. https://agentmart.dev/skills/cxcscmu-scala-option-either (last updated 2026-10-24)