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

peyton-jones-practical-haskell佩顿琼斯实用哈斯克尔

Agent Skill

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

总安装

564

周安装

24

GitHub Stars

6

下载量

198
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:peyton-jones-practical-haskell(佩顿琼斯实用哈斯克尔)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/peyton-jones-practical-haskell
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill peyton-jones-practical-haskell
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill peyton-jones-practical-haskell

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合围绕仓库状态、代码变更或协作事项进行整理。peyton-jones-practical-haskell 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 可结合来源仓库和 README 核验具体用法。
  • 安装前建议确认权限范围和维护状态,避免越权操作。
  • 注意是否会触发联网、命令执行或文件读写,谨慎授权。

SKILL.md

Simon Peyton Jones Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍​‌‌‌‌​​‌‍​‌‌​‌​​​‍‌‌‌‌​​‌‌‍‌​​‌​‌‌‌‍​​​​‌​‌​‍‌‌​‌​‌​‌⁠‍⁠

Overview

Simon Peyton Jones is the principal architect of the Glasgow Haskell Compiler (GHC) and has spent decades making functional programming practical. He bridges the gap between theory and implementation, showing that pure functional programming can be efficient.

Core Philosophy

"Laziness keeps you honest."
"Purity is the key to reasoning about programs."
"The best programs are written by people who know what the compiler will do."

SPJ believes that laziness and purity, while seeming like constraints, actually unlock powerful reasoning and optimization opportunities.

Design Principles

  1. Laziness by Default: Evaluate only what's needed, when it's needed.
  2. Purity Enables Optimization: The compiler can transform pure code freely.
  3. Types Prevent Bugs: Strong static typing catches errors at compile time.
  4. Understand the Runtime: Know how your code executes to write it well.

When Writing Code

Always

  • Understand strictness and laziness in your code
  • Use bang patterns when strictness matters
  • Profile before optimizing
  • Write small, composable functions
  • Let the compiler inline and specialize
  • Use Core output to understand performance

Never

  • Build up large lazy thunks accidentally
  • Ignore space leaks
  • Fight the garbage collector
  • Assume laziness is always good (or bad)
  • Micro-optimize without profiling

Prefer

  • Strict data fields for accumulators
  • Fusion-friendly operations (map, filter, fold)
  • Stream processing over building lists
  • Newtypes for zero-cost abstraction
  • GHC pragmas for performance hints

Code Patterns

Understanding Laziness

-- Lazy: this list is never fully in memory
naturals :: [Integer]
naturals = [1..]

-- Take only what you need
firstTen = take 10 naturals  -- [1..10]

-- Infinite data structures work!
fibs :: [Integer]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

fib100 = fibs !! 100  -- Computes only what's needed

-- BUT: laziness can cause space leaks
-- BAD: builds up a chain of thunks
badSum :: [Int] -> Int
badSum = foldl (+) 0
-- badSum [1,2,3] builds: ((0+1)+2)+3 as thunks!

-- GOOD: strict left fold
goodSum :: [Int] -> Int
goodSum = foldl' (+) 0
-- Forces evaluation at each step

import Data.List (foldl')

Strictness Annotations

{-# LANGUAGE BangPatterns #-}

-- Bang patterns force evaluation
strictSum :: [Int] -> Int
strictSum = go 0
  where
    go !acc []     = acc      -- !acc is strict
    go !acc (x:xs) = go (acc + x) xs

-- Strict data fields
data Point = Point !Double !Double
-- Fields are evaluated when Point is constructed

-- Versus lazy (default):
data LazyPoint = LazyPoint Double Double
-- Fields can be thunks

-- UNPACK for removing indirection
data Vec3 = Vec3 {-# UNPACK #-} !Double
                 {-# UNPACK #-} !Double
                 {-# UNPACK #-} !Double
-- Stores three doubles directly, no pointers

Fusion and Deforestation

-- GHC can fuse pipelines to avoid intermediate lists

-- This looks like it builds 3 lists:
result = sum . map (*2) . filter even $ [1..1000000]

-- But GHC fuses it into a single loop!
-- No intermediate lists are allocated

-- Write in fusion-friendly style:
-- Use map, filter, foldr, concatMap, etc.
-- Avoid: length, (!!), reverse in hot paths

-- The RULES pragma enables fusion
{-# RULES
"map/map" forall f g xs. map f (map g xs) = map (f . g) xs
"map/filter" forall f p xs.
    map f (filter p xs) = foldr (\x ys -> if p x then f x : ys else ys) [] xs
#-}

-- GHC's list fusion uses foldr/build:
-- build (\c n -> ... c ... n ...) >>= foldr c n
-- fuses to: ... c ... n ...

Newtypes for Zero-Cost Abstraction

-- newtype has no runtime overhead
newtype UserId = UserId Int
    deriving (Eq, Ord, Show)

newtype Email = Email String
    deriving (Eq, Show)

-- Type safety with zero cost
createUser :: UserId -> Email -> User
createUser uid email = ...

-- Cannot accidentally swap arguments!
-- createUser someEmail someUserId  -- Type error!

-- GeneralizedNewtypeDeriving for free instances
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

newtype Money = Money Int
    deriving (Eq, Ord, Num, Show)

-- Now you can do: Money 100 + Money 50 = Money 150

Monomorphism and Specialization

-- Polymorphic code has overhead (dictionary passing)
genericSum :: Num a => [a] -> a
genericSum = foldl' (+) 0

-- SPECIALIZE to remove overhead for known types
{-# SPECIALIZE genericSum :: [Int] -> Int #-}
{-# SPECIALIZE genericSum :: [Double] -> Double #-}

-- Or use INLINABLE to let GHC specialize at use sites
{-# INLINABLE genericSum #-}

-- For hot code, monomorphic is faster
intSum :: [Int] -> Int
intSum = foldl' (+) 0

Understanding Core

-- Use -ddump-simpl to see GHC Core output
-- Core shows what GHC actually compiles

-- Example: does this fuse?
test :: [Int] -> Int
test = sum . map (+1) . filter even

-- Compile with: ghc -O2 -ddump-simpl Test.hs
-- Look for single recursive function (fused)
-- vs multiple (not fused)

-- Key Core concepts:
-- - let: allocation
-- - case: evaluation (forcing)
-- - λ: function
-- - Type applications: @Int, @Bool

-- Fewer lets = less allocation
-- Strategic cases = proper strictness

Efficient Recursion

-- Tail recursion with accumulator
factorial :: Integer -> Integer
factorial n = go n 1
  where
    go 0 !acc = acc
    go n !acc = go (n-1) (n*acc)

-- Worker/wrapper transformation
-- Expose strict worker, wrap with friendly interface
{-# INLINE factorial #-}

-- Avoid: naive recursion with growing stack
badFactorial :: Integer -> Integer
badFactorial 0 = 1
badFactorial n = n * badFactorial (n-1)
-- Builds: n * (n-1) * (n-2) * ... * 1 as thunks

-- Use continuation-passing for complex control flow
data Tree a = Leaf a | Node (Tree a) (Tree a)

sumTree :: Num a => Tree a -> a
sumTree t = go t id
  where
    go (Leaf x) k = k x
    go (Node l r) k = go l (\sl -> go r (\sr -> k (sl + sr)))

Mental Model

SPJ approaches Haskell by asking:

  1. What gets evaluated when? Understand lazy vs strict
  2. Where are the thunks? Potential space leaks
  3. Will this fuse? Intermediate structures eliminated?
  4. What does Core look like? The ground truth
  5. Is this inlined? Key for performance

Signature SPJ Moves

  • Bang patterns for strategic strictness
  • UNPACK for unboxed fields
  • INLINE/INLINABLE for specialization
  • Fusion-friendly combinators
  • Worker/wrapper pattern
  • Core inspection for optimization

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.47%
按下载量换算68

Claude

29.68%
按下载量换算59

Cursor

17.18%
按下载量换算34

Gemini CLI

9.14%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

来源信息

继续浏览同类 Skills