effect-patterns-value-handling
БесплатноБез исполняемых скриптовНе проверенEffect-TS patterns for Value Handling. Use when working with value handling in Effect-TS applications.
от PaulJPhilp★ 807 звёзд на GitHubОб этом скилле
Effect-TS Patterns: Value Handling
This skill provides 2 curated Effect-TS patterns for value handling. Use this skill when working on tasks related to:
- value handling
- Best practices in Effect-TS applications
- Real-world patterns and solutions
🟡 Intermediate Patterns
Optional Pattern 1: Handling None and Some Values
Rule: Use Option to represent values that may not exist, replacing null/undefined with type-safe Option that forces explicit handling.
Good Example:
This example demonstrates Option handling patterns.
import { Effect, Option } from "effect";
interface User {
id: string;
name: string;
email: string;
}
interface Profile {
bio: string;
website?: string;
location?: string;
}
const program = Effect.gen(function* () {
console.log(
`\n[OPTION HANDLING] None/Some values and pattern matching\n`
);
// Example 1: Creating Options
console.log(`[1] Creating Option values:\n`);
const someValue: Option.Option<string> = Option.some("data");
const noneValue: Option.Option<string> = Option.none();
const displayOption = <T,>(opt: Option.Option<T>, label: string) =>
Effect.gen(function* () {
if (Option.isSome(opt)) {
yield* Effect.log(`${label}: Some(${opt.value})`);
} else {
yield* Effect.log(`${label}: None`);
}
});
yield* displayOption(someValue, "someValue");
yield* displayOption(noneValue, "noneValue");
// Example 2: Creating from nullable values
console.log(`\n[2] Converting nullable to Option:\n`);
const possiblyNull = (shouldExist: boolean): string | null =>
shouldExist ? "found" : null;
const toOption = (value: string | null | undefined): Option.Option<string> =>
value ? Option.some(value) : Option.none();
const opt1 = toOption(possiblyNull(true));
const opt2 = toOption(possiblyNull(false));
yield* displayOption(opt1, "toOption(found)");
yield* displayOption(opt2, "toOption(null)");
// Example 3: Pattern matching on Option
console.log(`\n[3] Pattern matching with match():\n`);
const userId: Option.Option<string> = Option.some("user-123");
const message = Option.match(userId, {
onSome: (id) => `User ID: ${id}`,
onNone: () => "No user found",
});
yield* Effect.log(`[MATCH] ${message}`);
const emptyUserId: Option.Option<string> = Option.none();
const emptyMessage = Option.match(emptyUserId, {
onSome: (id) => `User ID: ${id}`,
onNone: () => "No user found",
});
yield* Effect.log(`[MATCH] ${emptyMessage}\n`);
// Example 4: Transforming with map
console.log(`[4] Transforming values with map():\n`);
const userCount: Option.Option<number> = Option.some(42);
const doubled = Option.map(userCount, (count) => count * 2);
yield* displayOption(doubled, "doubled");
// Chaining maps
const email: Option.Option<string> = Option.some("[email protected]");
const domain = Option.map(email, (e) =>
e.split("@")[1] ?? "unknown"
);
yield* displayOption(domain, "email domain");
// Example 5: Chaining with flatMap
console.log(`\n[5] Chaining operations with flatMap():\n`);
const findUser = (id: string): Option.Option<User> =>
id === "user-1"
? Option.some({ id, name: "Alice", email: "[email protected]" })
: Option.none();
const getProfile = (userId: string): Option.Option<Profile> =>
userId === "user-1"
? Option.some({ bio: "Developer", website: "alice.dev" })
: Option.none();
const userId2 = Option.some("user-1");
// Chained operations: userId -> user -> profile
const profileChain = Option.flatMap(userId2, (id) =>
Option.flatMap(findUser(id), (user) =>
getProfile(user.id)
)
);
const profileResult = Option.match(profileChain, {
onSome: (profile) => `Bio: ${profile.bio}, Website: ${profile.website}`,
onNone: () => "No profile found",
});
yield* Effect.log(`[CHAIN] ${profileResult}\n`);
// Example 6: Fallback values with getOrElse
console.log(`[6] Default values with getOrElse():\n`);
const optionalStatus: Option.Option<string> = Option.none();
const status = Option.getOrElse(optionalStatus, () => "unknown");
yield* Effect.log(`[DEFAULT] Status: ${status}`);
// Real value
const knownStatus: Option.Option<string> = Option.some("active");
const realStatus = Option.getOrElse(knownStatus, () => "unknown");
yield* Effect.log(`[VALUE] Status: ${realStatus}\n`);
// Example 7: Filter with predicate
console.log(`[7] Filtering with conditions:\n`);
const ageOption: Option.Option<number> = Option.some(25);
const isAdult = Option.filter(ageOption, (age) => age >= 18);
yield* displayOption(isAdult, "Adult check (25)");
const ageOption2: Option.Option<number> = Option.some(15);
const isAdult2 = Option.filter(ageOption2, (age) => age >= 18);
yield* displayOption(isAdult2, "Adult check (15)");
// Example 8: Multiple Options (all present?)
console.log(`\n[8] Combining multiple Options:\n`)
Установить effect-patterns-value-handling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл effect-patterns-value-handling?
Effect-TS patterns for Value Handling. Use when working with value handling in Effect-TS applications.
Как установить скилл effect-patterns-value-handling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл effect-patterns-value-handling запускает скрипты?
Нет, скилл состоит только из инструкций (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