agentsclimarketplace

Python scala functional

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-opus-4-6/python-scala-translation/python-scala-functional

Guide for translating Python functional patterns (map, flatMap, Option, monads) to idiomatic Scala.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill python-scala-functional

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

SKILL.md

1.1 KB, 271 tokens by cl100k_base, as published. Nobody here has run it

Python to Scala Functional Patterns

Functor / Monad Simulation -> Proper Scala Types

// Python simulates functors; Scala has them natively via map/flatMap
class TokenFunctor[A](val get: A) {
  def map[B](f: A => B): TokenFunctor[B] = new TokenFunctor(f(get))
  def flatMap[B](f: A => TokenFunctor[B]): TokenFunctor[B] = f(get)
  def getOrElse(default: => A): A = if (get != null) get else default
}

Option Handling

// Python: return None -> Scala: Option[T]
// Python: if x is None -> Scala: x match { case None => ... case Some(v) => ... }
// Python: x or default -> Scala: x.getOrElse(default)

Higher-Order Functions

// Python: Callable[[T], Token] -> Scala: T => Token
// Python: Callable[[T], Token | None] -> Scala: T => Option[Token]

Lazy Evaluation

// Python: yield (generator) -> Scala: Iterator via .iterator.map
def tokenizeBatch(values: Iterable[T]): Iterator[Token] =
  values.iterator.map(tokenize)

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. 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.