Toolverse
All skills

python-scala-idioms

by benchflow-ai

Guide for writing idiomatic Scala when translating from Python. Use when the goal is not just syntactic translation but producing clean, idiomatic Scala code. Covers immutability, expression-based style, sealed hierarchies, and common Scala conventions.

Installation

Pick a client and clone the repository into its skills directory.

Installation

Quick info

Category
Backend
Views
1

About this skill

Guide for writing idiomatic Scala when translating from Python. Use when the goal is not just syntactic translation but producing clean, idiomatic Scala code. Covers immutability, expression-based style, sealed hierarchies, and common Scala conventions.

How to use

  1. Przygotuj kod Python, który chcesz przetłumaczyć na Scalę. Umiejętność działa najlepiej, gdy masz jasny cel — nie chodzi o dosłowny przekład, ale o przepisanie logiki w idiomatycznym stylu Scali.

  2. Zapoznaj się z pięcioma głównymi zasadami: preferuj immutability (używaj val zamiast var), pisz kod oparty na wyrażeniach (wszystko powinno zwracać wartość), wykorzystuj system typów Scali, stosuj pattern matching zamiast łańcuchów if-else, oraz unikaj null — używaj Option, Either lub Try.

  3. Dla każdej klasy lub funkcji z Pythona zastosuj zasadę immutability: zamiast modyfikować stan obiektu, zwracaj nowy obiekt ze zmienionymi wartościami. Przykład: zamiast self.count += 1, użyj copy(count = count + 1).

  4. Zamień instrukcje warunkowe na pattern matching. Jeśli w Pythonie masz serię if-elif-else, w Scali napisz match expression, które jest bardziej czytelne i bezpieczne typowo.

  5. Modeluj domeny za pomocą sealed hierarchies — zamiast sprawdzać stringi, zdefiniuj sealed trait z konkretnymi case classami dla każdego wariantu. To daje ci bezpieczeństwo kompilacji i wsparcie pattern matchingu.

  6. Przejrzyj przetłumaczony kod pod kątem null — wszędzie, gdzie Python mógłby zwrócić None, użyj Scala Option. Gdzie mogą pojawić się błędy, rozważ Either lub Try zamiast wyjątków.

Related skills

pdf-to-markdown

by aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions \

Backend
355664

patent-search

by RobThePCGuy

Advanced prior art search using the PatentsView API. Use this skill when users need to search for patents, perform prior art searches, analyze patent landscapes, or find patents by inventor, title, date range, or technical fields. Helps with patent research, freedom to operate

Backend
36218

scientific-writing

by K-Dense-AI

Write scientific manuscripts. IMRAD structure, citations (APA/AMA/Vancouver), figures/tables, reporting guidelines (CONSORT/STROBE/PRISMA), abstracts, for research papers and journal submissions.

Backend
47191

fastapi-templates

by wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

Backend
327582

youtube-transcribe-skill

by feiskyer

Extract subtitles/transcripts from a YouTube video URL and save as a local file. Use when you need to extract subtitles from a YouTube video.

Backend
24178

openspec

by ruan-cat

OpenSpec 中文版规范助手 - 规范驱动的 AI 编程开发,帮助初始化、创建提案、编写规格、校验格式并归档变更。触发条件: 当用户提及 openspec、规范文档、需求管理、变更提案、spec-driven development 等关键词时主动调用。

Backend
27122