Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

wadler-monadic-elegance沃德勒单子优雅

Agent Skill

wadler-monadic-elegance 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

216

周安装

9

GitHub Stars

6

下载量

72
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:wadler-monadic-elegance(沃德勒单子优雅)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/wadler-monadic-elegance
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill wadler-monadic-elegance
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill wadler-monadic-elegance

简介

用于处理 GitHub 仓库、Issue、Pull Request 等代码协作信息,帮助 Agent 跟踪项目状态和变更。

  • 适用于开发类场景,可在 Codex、Claude、Cursor、Gemini CLI 中集成以支持代码审查与协作流程。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,具体用法需参考原始 README 文档。
  • 使用前建议确认权限范围和维护状态,避免触发不必要的联网或文件读写操作。
  • wadler-monadic-elegance 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Philip Wadler Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍​‌‌‌‌​​​‍‌​​​‌​‌‌‍‌​​​​‌‌‌‍​​​​‌‌‌‌‍​​​​‌​‌​‍​​​​​​‌‌⁠‍⁠

Overview

Philip Wadler is a principal designer of Haskell, contributor to Java generics, and the person who brought monads from category theory into practical programming. His famous paper "Propositions as Types" illuminates the deep connection between logic and computation.

Core Philosophy

"The essence of functional programming is that programs are built by composing functions."
"Monads are just monoids in the category of endofunctors."
"A monad is a way to structure computations."

Wadler sees programming as applied mathematics—types are propositions, programs are proofs, and monads are the universal pattern for composition.

Design Principles

  1. Types Are Propositions: A type signature is a theorem; the implementation is its proof.
  2. Monads Everywhere: IO, Maybe, List, State—all are instances of one pattern.
  3. Parametric Polymorphism: Generic code that works for any type.
  4. Theorems for Free: From the type, derive properties the code must have.

When Writing Code

Always

  • Let types guide your implementation
  • Use monadic composition for effects
  • Exploit parametricity for correctness
  • Derive functions from types systematically
  • Prefer point-free style when it aids clarity
  • Think in terms of algebraic laws

Never

  • Fight the type system
  • Use partial functions without wrapping in Maybe
  • Ignore the monad laws
  • Mix effects without explicit structure
  • Sacrifice correctness for convenience

Prefer

  • Maybe over null
  • Either over exceptions
  • Monadic composition over nested callbacks
  • Type classes over ad-hoc polymorphism
  • Algebraic reasoning over testing alone

Code Patterns

The Monad Pattern

-- A monad has three components:
-- 1. A type constructor: m a
-- 2. return: a -> m a (inject a value)
-- 3. bind: m a -> (a -> m b) -> m b (sequence computations)

-- Maybe monad: computations that might fail
safeDivide :: Double -> Double -> Maybe Double
safeDivide _ 0 = Nothing
safeDivide x y = Just (x / y)

-- Composition with bind (>>=)
compute :: Double -> Double -> Double -> Maybe Double
compute x y z = safeDivide x y >>= \r -> safeDivide r z

-- Do notation (syntactic sugar for bind)
compute' :: Double -> Double -> Double -> Maybe Double
compute' x y z = do
    r <- safeDivide x y
    safeDivide r z

-- List monad: computations with multiple results
pairs :: [a] -> [b] -> [(a, b)]
pairs xs ys = do
    x <- xs
    y <- ys
    return (x, y)

-- Equivalent to:
pairs' xs ys = xs >>= \x -> ys >>= \y -> return (x, y)

-- Or with list comprehension:
pairs'' xs ys = [(x, y) | x <- xs, y <- ys]

-- IO monad: computations with side effects
greet :: IO ()
greet = do
    putStrLn "What is your name?"
    name <- getLine
    putStrLn ("Hello, " ++ name ++ "!")

The Monad Laws

-- Every monad must satisfy three laws:

-- 1. Left identity: return a >>= f  ≡  f a
-- 2. Right identity: m >>= return  ≡  m
-- 3. Associativity: (m >>= f) >>= g  ≡  m >>= (\x -> f x >>= g)

-- These laws ensure composition behaves predictably
-- Violating them leads to subtle bugs

-- Example: verifying Maybe satisfies the laws
-- Left identity:
--   return a >>= f
--   = Just a >>= f
--   = f a ✓

-- Right identity:
--   Just x >>= return
--   = return x
--   = Just x ✓

-- Associativity holds by case analysis on m

Functor and Applicative

-- Functor: things you can map over
-- fmap :: (a -> b) -> f a -> f b
-- Law: fmap id = id
-- Law: fmap (f . g) = fmap f . fmap g

incrementAll :: [Int] -> [Int]
incrementAll = fmap (+1)

-- Applicative: functors you can combine
-- pure :: a -> f a
-- (<*>) :: f (a -> b) -> f a -> f b

-- Combine Maybe values
addMaybe :: Maybe Int -> Maybe Int -> Maybe Int
addMaybe mx my = pure (+) <*> mx <*> my
-- addMaybe (Just 3) (Just 4) = Just 7
-- addMaybe Nothing (Just 4) = Nothing

-- The hierarchy: Functor → Applicative → Monad
-- Every Monad is an Applicative
-- Every Applicative is a Functor

Parametric Polymorphism and Theorems for Free

-- From the type alone, we can derive properties

-- What can this function possibly do?
mystery :: a -> a
-- It can ONLY be the identity function!
-- It cannot inspect 'a', so it can only return what it received.

-- What about this?
mystery2 :: [a] -> [a]
-- It can reorder, duplicate, or drop elements
-- But it cannot fabricate new 'a' values
-- Therefore: map f . mystery2 = mystery2 . map f

-- This is a "free theorem" - derived purely from the type

-- Practical example:
reverse :: [a] -> [a]
-- Free theorem: map f . reverse = reverse . map f
-- We get this property for free from the type!

Monad Transformers

import Control.Monad.Trans.Maybe
import Control.Monad.Trans.State
import Control.Monad.Trans.Class (lift)

-- Combine effects with monad transformers
type App a = MaybeT (StateT Int IO) a

-- MaybeT adds failure
-- StateT adds mutable state
-- IO adds side effects

runApp :: App a -> Int -> IO (Maybe a, Int)
runApp app initialState = runStateT (runMaybeT app) initialState

example :: App String
example = do
    lift $ lift $ putStrLn "Starting..."  -- IO
    lift $ modify (+1)                     -- State
    n <- lift get
    if n > 10
        then return "Big number"
        else MaybeT $ return Nothing       -- Maybe (failure)

Type-Driven Development

-- Start with the type, derive the implementation

-- Problem: safely index into a list
-- Type tells us what we need:
safeIndex :: [a] -> Int -> Maybe a

-- Implementation follows from the type:
safeIndex [] _ = Nothing
safeIndex (x:_) 0 = Just x
safeIndex (_:xs) n
    | n < 0     = Nothing
    | otherwise = safeIndex xs (n - 1)

-- Problem: traverse a structure with effects
-- The type guides us completely:
traverse :: (Applicative f) => (a -> f b) -> [a] -> f [b]
traverse _ [] = pure []
traverse f (x:xs) = (:) <$> f x <*> traverse f xs

-- Usage:
-- traverse readFile ["a.txt", "b.txt"] :: IO [String]
-- traverse Just [1, 2, 3] :: Maybe [Int]

Mental Model

Wadler approaches programming by asking:

  1. What is the type? The type is the specification
  2. What are the laws? Algebraic properties guide implementation
  3. Is this a known pattern? Functor, Applicative, Monad, etc.
  4. What theorems are free? Derive properties from types
  5. Does this compose? Good abstractions compose cleanly

Signature Wadler Moves

  • Monadic do-notation for sequencing effects
  • Free theorems from parametric types
  • Monad transformers for combined effects
  • Type classes for ad-hoc polymorphism
  • Algebraic laws as correctness criteria
  • Category theory as design guide

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.91%
按下载量换算26

Claude

31.4%
按下载量换算23

Cursor

18.77%
按下载量换算14

Gemini CLI

9.8%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills