agentsclimarketplace

Python scala generics

Skill cxcscmu/SkillLearnBench/skills/b4-skill-creator-gemini-3-flash-preview/python-scala-translation/python-scala-generics

Guidelines for translating Python TypeVars and Protocols to Scala Generics and Traits.From its SKILL.md

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

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

SKILL.md

0.9 KB, 219 tokens by cl100k_base, as published. Nobody here has run it

Python to Scala Generics Mapping

Variance

  • Invariant: Python TypeVar("T") -> Scala [T]
  • Covariant: Python TypeVar("T_co", covariant=True) -> Scala [+T]
  • Contravariant: Python TypeVar("T_contra", contravariant=True) -> Scala [-T]

Structural Typing (Protocols)

  • Python Protocol -> Scala trait.
  • If structural typing is strictly required in Scala, use "duck typing" via import scala.language.reflectiveCalls, but standard trait with inheritance is preferred for performance and type safety.

Type Bounds

  • Python TypeVar("T", bound=Class) -> Scala [T <: Class]
  • Python TypeVar("T", int, float) -> Scala doesn't have Union types in 2.13 in this specific way. Use Either, sealed trait hierarchies, or Type Classes (e.g., Numeric[T]).

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.