agentsclimarketplace

Run1 scala functional error handling

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-gemini-3.1-pro-preview/python-scala-translation/run1_scala-functional-error-handling

[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_scala-functional-error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Handling absence of values and errors in Scala using Option, Try, and Either instead of nulls and exceptions.

SKILL.md

1.3 KB, as published. Nobody here has run it

Scala discourages the use of null and exception throwing for control flow, preferring functional error handling types from the standard library.

1. Handling Missing Values (Option)

Instead of returning None as in Python, Scala methods should return Option[T].

Python:

def get_metadata(self) -> dict | None:
    return self.metadata if self.metadata else None

Scala:

def getMetadata: Option[Map[String, String]] = {
  if (metadata.nonEmpty) Some(metadata) else None
}

2. Handling Exceptions (Try)

When parsing data (like numbers or dates), Python uses try...except. Scala uses scala.util.Try, which can be easily mapped to an Option if you only care about success/failure.

Python:

def parse_number(text: str) -> float | None:
    try:
        return float(text)
    except ValueError:
        return None

Scala:

import scala.util.Try

def parseNumber(text: String): Option[Double] = {
  Try(text.toDouble).toOption
}

3. Collection Safety

When operating on collections, avoid operations that can throw exceptions (like .head). Use safe alternatives (like .headOption).

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.