effect-patterns-streams-getting-started
БесплатноБез исполняемых скриптовНе проверенEffect-TS patterns for Streams Getting Started. Use when working with streams getting started in Effect-TS applications.
от PaulJPhilp★ 807 звёзд на GitHubОб этом скилле
Effect-TS Patterns: Streams Getting Started
This skill provides 4 curated Effect-TS patterns for streams getting started. Use this skill when working on tasks related to:
- streams getting started
- Best practices in Effect-TS applications
- Real-world patterns and solutions
🟢 Beginner Patterns
Your First Stream
Rule: Use Stream to process sequences of data lazily and efficiently.
Good Example:
import { Effect, Stream } from "effect"
// Create a stream from explicit values
const numbers = Stream.make(1, 2, 3, 4, 5)
// Create a stream from an array
const fromArray = Stream.fromIterable([10, 20, 30])
// Create a single-value stream
const single = Stream.succeed("hello")
// Transform and run the stream
const program = numbers.pipe(
Stream.map((n) => n * 2), // Double each number
Stream.filter((n) => n > 4), // Keep only > 4
Stream.runCollect // Collect results
)
Effect.runPromise(program).then((chunk) => {
console.log([...chunk]) // [6, 8, 10]
})
Anti-Pattern:
Don't use regular arrays when you need lazy processing or async operations:
// Anti-pattern: Eager processing, all in memory
const numbers = [1, 2, 3, 4, 5]
const doubled = numbers.map((n) => n * 2)
const filtered = doubled.filter((n) => n > 4)
This loads everything into memory immediately. Use Stream when:
- Data is large or potentially infinite
- Data arrives asynchronously
- You need backpressure or resource management
Rationale:
A Stream is a lazy sequence of values that can be processed one at a time. Create streams with Stream.make, Stream.fromIterable, or Stream.succeed.
Streams are Effect's answer to processing sequences of data. Unlike arrays which hold all values in memory at once, streams produce values on demand. This makes them ideal for:
- Large datasets - Process millions of records without loading everything into memory
- Async data - Handle data that arrives over time (files, APIs, events)
- Composable pipelines - Chain transformations that work element by element
Stream vs Effect - When to Use Which
Rule: Use Effect for single values, Stream for sequences of values.
Good Example:
import { Effect, Stream } from "effect"
// ============================================
// EFFECT: Single result operations
// ============================================
// Fetch one user - returns Effect<User>
const fetchUser = (id: string) =>
Effect.tryPromise(() =>
fetch(`/api/users/${id}`).then((r) => r.json())
)
// Read entire config - returns Effect<Config>
const loadConfig = Effect.tryPromise(() =>
fetch("/config.json").then((r) => r.json())
)
// ============================================
// STREAM: Multiple values operations
// ============================================
// Process file line by line - returns Stream<string>
const fileLines = Stream.fromIterable([
"line 1",
"line 2",
"line 3",
])
// Generate events over time - returns Stream<Event>
const events = Stream.make(
{ type: "click", x: 10 },
{ type: "click", x: 20 },
{ type: "scroll", y: 100 },
)
// ============================================
// CONVERTING BETWEEN THEM
// ============================================
// Effect → Stream (single value becomes 1-element stream)
const effectToStream = Stream.fromEffect(fetchUser("123"))
// Stream → Effect (collect all values into array)
const streamToEffect = Stream.runCollect(fileLines)
// Stream → Effect (process each value for side effects)
const processAll = fileLines.pipe(
Stream.runForEach((line) => Effect.log(`Processing: ${line}`))
)
// ============================================
// DECISION GUIDE
// ============================================
// Use Effect when:
// - Fetching a single resource
// - Computing a single result
// - Performing one action
// Use Stream when:
// - Reading files line by line
// - Processing paginated API results
// - Handling real-time events
// - Processing large datasets
// - Building data pipelines
Rationale:
Use Effect when your operation produces a single result. Use Stream when your operation produces multiple values over time.
Both Effect and Stream are lazy and composable, but they serve different purposes:
| Aspect | Effect | Stream |
|---|---|---|
| Produces | One value | Zero or more values |
| Memory | Holds one result | Processes incrementally |
| Use case | API call, DB query | File lines, events, batches |
Running and Collecting Stream Results
Rule: Choose the right Stream.run* method based on what you need from the results.
Good Example:
import { Effect, Stream, Option } from "effect"
const numbers = Stream.make(1, 2, 3, 4, 5)
// ============================================
// runCollect - Get all results as a Chunk
// ============================================
const c
Установить effect-patterns-streams-getting-started в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл effect-patterns-streams-getting-started?
Effect-TS patterns for Streams Getting Started. Use when working with streams getting started in Effect-TS applications.
Как установить скилл effect-patterns-streams-getting-started?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл effect-patterns-streams-getting-started запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic