Skillpedia
برمجة عامة48k · #4645

fp-pragmatic

ما الذي تفعله

يعلّم هذا الدليل المفاهيم الأساسية للبرمجة الوظيفية بطريقة عملية، مع التركيز على ما يهم فعلًا لتحسين كودك دون تعقيد.

متى تستخدمها

  • ✓للبدء في البرمجة الوظيفية باستخدام TypeScript.
  • ✓عندما تريد استكشاف أفكار البرمجة الوظيفية بسرعة (نهج 80/20).
  • ✓لفهم متى تفيد البرمجة الوظيفية، ومتى يكون الأفضل إبقاء الكود بسيطًا.

رابط المهارة

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-pragmatic/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-pragmatic/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أبدأ بالبرمجة الوظيفية في TypeScript بطريقة بسيطة؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يركز على الأنماط المفيدة، ويبتعد عن المصطلحات الأكاديمية، ويوضح كيفية تطبيق المفاهيم التي تحقق نتائج حقيقية.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Pragmatic Functional Programming

Read this first. This guide cuts through the academic jargon and shows you what actually matters. No category theory. No abstract nonsense. Just patterns that make your code better.

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use

  • You want a pragmatic starting point for fp-ts or functional programming in TypeScript.
  • The task is exploratory or educational and needs an 80/20 view of what is actually worth adopting.
  • You need guidance on when FP helps and when it is better to keep code simple.

When NOT to Use FP

Functional programming is not always the answer. Here's when to keep it simple.

Simple Null Checks

// Just use optional chaining - it's built into the language
const city = user?.address?.city ?? 'Unknown'

// DON'T overcomplicate it
const city = pipe(
  O.fromNullable(user),
  O.flatMap(u => O.fromNullable(u.address)),
  O.flatMap(a => O.fromNullable(a.city)),
  O.getOrElse(() => 'Unknown')
)

Simple Loops

// A for loop is fine when you need early exit or complex logic
function findFirst(items: Item[], predicate: (i: Item) => boolean): Item | null {
  for (const item of items) {
    if (predicate(item)) return item
  }
  return null
}

// DON'T force FP when it doesn't help
const result = pipe(
  items,
  A.findFirst(predicate),
  O.toNullable
)

Performance-Critical Code

// For hot paths, imperative is faster (no intermediate arrays)
function sumLarge(numbers: number[]): number {
  let sum = 0
  for (let i = 0; i < numbers.length; i++) {
    sum += numbers[i]
  }
  return sum
}

// fp-ts creates intermediate structures
const sum = pipe(numbers, A.reduce(0, (acc, n) => acc + n))

When Your Team Doesn't Know FP

If you're the only one who can read the code, it's not good code.

// If your team knows this pattern
async function getUser(id: string): Promise<User | null> {
  try {
    const response = await fetch(`/api/users/${id}`)
    if (!response.ok) return null
    return await response.json()
  } catch {
    return null
  }
}

// Don't force this on them
const getUser = (id: string): TE.TaskEither<Error, User> =>
  pipe(
    TE.tryCatch(() => fetch(`/api/users/${id}`), E.toError),
    TE.flatMap(r => r.ok ? TE.right(r) : TE.left(new Error('Not found'))),
    TE.flatMap(r => TE.tryCatch(() => r.json(), E.toError))
  )

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.
الأسئلة الشائعة

ما هي البرمجة الوظيفية؟

هي أسلوب برمجي تبني فيه البرامج عبر التفكير في دوال تحوّل البيانات، بدلًا من تغيير حالة الأشياء.

متى لا ينبغي استخدام البرمجة الوظيفية؟

تجنبها عندما يحل الكود البسيط المشكلة (مثل فحوص null السهلة)، أو عندما لا يكون فريقك معتادًا على هذا الأسلوب.

هل يعلّم هذا الدليل كل شيء عن البرمجة الوظيفية؟

لا، يركز على 20% من المفاهيم التي تحقق 80% من النتائج، دون المصطلحات الأكاديمية.

التفاصيل

الوصف الأصلي من المؤلف

A practical, jargon-free guide to functional programming - the 80/20 approach that gets results without the academic overhead

repo: sickn33/agentic-awesome-skills

الشعبية

نجوم GitHub
48k
الترتيب
#4645
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة