data-types_skill
- TypeScript
5
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill andrueandersoncs/claude-skill-effect-ts --skill data-types- SKILL.md7.3 KB
Overview
This skill explains Effect's built-in data types and functional data structures. It covers Option, Either, Cause, Exit, Data (TaggedEnum and Class), Chunk, Duration, DateTime, HashMap, HashSet, and Redacted to help you reason about values, errors, collections, and time in Effect programs.
How this skill works
I summarize each type, show common constructors and matchers, and demonstrate typical transformations and conversions to Effect. The guide explains how to convert Option/Either into Effect failures or successes, inspect Cause and Exit for failure diagnostics, use Data for structural equality and tagged domain errors, and work with immutable collections like Chunk, HashMap, and HashSet. It also covers Duration and DateTime utilities and how to redact secrets for safe logging.
When to use it
- Use Option for nullable or optionally-present values instead of null/undefined.
- Use Either for operations that return success or domain-specific failure without throwing.
- Use Cause and Exit when you need full failure diagnostics from Effects.
- Use Data.Class or Data.TaggedEnum for value equality and expressive, typed domain models.
- Use Chunk for indexed, immutable sequences optimized for Effect workflows and streaming.
- Use Duration/DateTime for type-safe time computations and HashMap/HashSet for immutable hashed collections.
Best practices
- Always convert Option to Effect when absence should fail the workflow; prefer explicit failure handling.
- Prefer Either for validation flows so you can map or accumulate errors without exceptions.
- Use Schema.TaggedError for domain errors to enable pattern matching and catchTag semantics.
- Prefer Chunk over plain arrays in Effect-heavy code for performance and API consistency.
- Wrap secrets in Redacted to avoid accidental exposure in logs and debug output.
- Use Duration and DateTime helpers to avoid manual milliseconds arithmetic and timezone mistakes.
Example use cases
- Look up optional configuration with Option and fail the Effect with a tagged UserNotFound error when missing.
- Perform input validation with Either, mapLeft to domain errors, and chain transformations with flatMap.
- Run an Effect and inspect Exit to pretty-print Cause for logging detailed failure traces.
- Model immutable domain entities with Data.Class for structural equality checks and use Data.TaggedEnum for algebraic types like shapes.
- Process a stream of events using Chunk for efficient slicing, mapping, and reductions.
- Store and query immutable key-value state with HashMap and membership sets with HashSet; redact API keys before logging.
FAQ
Match the Option to return Effect.fail on None and Effect.succeed on Some, or use Effect.fromOption and map the error to a domain error.
When should I use Either vs throwing exceptions?
Use Either for predictable, typed errors and validations; prefer throwing only for unrecoverable defects. Either keeps error handling explicit and composable.