fp-either-ref
यह क्या करती है
यह टूल कंप्यूटर प्रोग्राम में errors को व्यवस्थित तरीके से संभालने में मदद करता है। यह बताता है कि कोई काम सफल हुआ (एक value के साथ) या असफल रहा (एक खास error message के साथ), और प्रोग्राम अचानक बंद नहीं होता।
कब इस्तेमाल करें
- ✓डेटा का उपयोग करने से पहले जांचना हो कि वह सही है या नहीं।
- ✓ऐसा काम करते समय जो असफल हो सकता है, जैसे कोई file पढ़ना।
- ✓ऐसे कोड को बदलने के लिए जो errors फेंकता है, ताकि उसे प्रोग्राम 'सफलता' या 'असफलता' के रूप में समझ सके।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-either-ref/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं कैसे जांच सकता हूं कि कोई email सही है या नहीं, और अगर नहीं है तो साफ़ error message कैसे दिखाऊं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
इसमें दो रास्ते तय किए जाते हैं: एक सफलता के लिए (अपेक्षित परिणाम के साथ) और दूसरा असफलता के लिए (समस्या के विवरण के साथ)। नतीजे के हिसाब से आप कौन सा रास्ता लेना है, यह चुन सकते हैं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Either Quick Reference
Either = success or failure. Right(value) or Left(error).
When to Use
- You need a quick fp-ts reference for typed synchronous error handling.
- The task involves validation, fallible operations, or converting throwing code to
Either. - You want a compact cheat sheet rather than a long tutorial.
Create
import * as E from 'fp-ts/Either'
E.right(value) // Success
E.left(error) // Failure
E.fromNullable(err)(x) // null → Left(err), else Right(x)
E.tryCatch(fn, toError) // try/catch → Either
Transform
E.map(fn) // Transform Right value
E.mapLeft(fn) // Transform Left error
E.flatMap(fn) // Chain (fn returns Either)
E.filterOrElse(pred, toErr) // Right → Left if pred fails
Extract
E.getOrElse(err => fallbackValue) // Get Right or default
E.match(onLeft, onRight) // Pattern match
E.toUnion(either) // E | A (loses type info)
Common Patterns
import { pipe, identity } from 'fp-ts/function'
import * as E from 'fp-ts/Either'
// Toy validation; an @ check is not complete email validation
const validateEmail = (s: string): E.Either<string, string> =>
s.includes('@') ? E.right(s) : E.left('Invalid email')
// Chain validations (stops at first error)
pipe(
E.right({ email: 'test@example.com', age: 25 }),
E.flatMap(d => pipe(validateEmail(d.email), E.map(() => d))),
E.flatMap(d => d.age >= 18 ? E.right(d) : E.left('Must be 18+'))
)
// Convert throwing code
const parseJson = (s: string) => E.tryCatch(
() => JSON.parse(s),
(e) => `Parse error: ${e}`
)
vs try/catch
// ❌ try/catch - errors not in types
try {
const data = JSON.parse(input)
process(data)
} catch (e) {
handleError(e)
}
// ✅ Either - errors explicit in types
pipe(
E.tryCatch(() => JSON.parse(input), String),
E.flatMap(data => E.tryCatch(() => process(data), String)),
E.match(handleError, identity)
)
Use Either when error type matters and you want to chain operations.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Reference scope
These are fp-ts 2.x fragments. Supply application variables, types, validators and imports, and check the installed version. map does not catch thrown exceptions. Task has no typed error channel; an improperly wrapped promise can still reject. Use tryCatch at fallible boundaries.
Official API: fp-ts modules.
अक्सर पूछे जाने वाले सवाल
'Right' और 'Left' में क्या अंतर है?
'Right' सफलता को दर्शाता है, जिसमें आपकी अपेक्षित value होती है। 'Left' असफलता को दर्शाता है, जिसमें हुई error का message या प्रकार होता है।
क्या मैं इसे उन कोड के साथ इस्तेमाल कर सकता हूं जो errors फेंक सकता है, जैसे file पढ़ना?
हां, इस टूल में `tryCatch` नाम का एक खास function है, जो ऐसे काम को 'Right' (सफलता) या 'Left' (असफलता) नतीजे में बदल देता है।
जब नतीजा सफलता या error हो सकता है, तो अंतिम परिणाम कैसे पाऊं?
`getOrElse` जैसे functions से error होने पर default value दी जा सकती है, और `match` से सफलता या error के हिसाब से अलग-अलग काम किए जा सकते हैं।
जानकारी
लेखक का मूल विवरण
Quick reference for Either type. Use when user needs error handling, validation, or operations that can fail with typed errors.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #4641
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।