Run3 scala functional parsing and error handling
Implement idiomatic Scala logic for parsing temporal/numeric data and handling batch processing using functional transformations and error types.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill run3_scala-functional-parsing-and-error-handlingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.3 KB, 255 tokens by cl100k_base, as published. Nobody here has run it
Functional Error Handling
Avoid returning null or throwing exceptions for expected failures (e.g., failed parsing). Use:
Option[Token]: When a result might be absent.Either[String, Token]: When you need to provide an error message upon failure.
Numeric and Temporal Parsing
- Numeric: Use
String.toDoubleOptionorString.toIntOptionto safely convert strings to numbers. If using a version where these aren't available, wrap the logic inscala.util.Try(s.toDouble).toOption. - Temporal: Use the
java.timepackage (e.g.,LocalDateTime,ZonedDateTime) andDateTimeFormatter. Wrap parsing logic in a functional container to handle malformed date strings gracefully.
Batch Processing
Instead of manual loops, use Scala's collection API for tokenizeBatch:
- Use
.map(tokenize)to transform a sequence of inputs into a sequence of tokens. - Use
.flatMapif the tokenization process returns anOptionand you wish to filter out unsuccessful attempts.
Standard Library Usage
Prefer Scala's standard library over reinventing logic. For example, use s.split("\\s+") or Regex for WhitespaceTokenizer logic.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.