agentleFS
rainoftimerainoftime/pl-skills/module-system/SKILL.md

module-system

Skill17 starsChanged 9 months agoApache-2.0View on GitHub

Implement module systems for organizing code, encapsulation, and namespace management.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Functors/Parameterized Modules: Create module-level functions

    line 28
  2. Distinctive:

    Use signatures for abstraction

    line 44
  3. Distinctive:

    Use functors for generic libraries

    line 46
  4. Distinctive:

    Consider cyclic dependencies carefully

    line 47
  5. Distinctive:

    When simple imports suffice

    line 85

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Module System

Module systems provide mechanisms for organizing code, encapsulating implementation details, and managing namespaces. They are essential for building large-scale software systems.

When to Use This Skill

  • Designing language module systems
  • Building large codebases
  • Implementing encapsulation
  • Managing dependencies
  • Teaching programming language design

What This Skill Does

  1. Namespace Management: Organize names into hierarchical namespaces
  2. Encapsulation: Hide implementation details
  3. Interface/Implementation Separation: Define signatures and structures
  4. Functors/Parameterized Modules: Create module-level functions
  5. Dependency Management: Handle module dependencies

Key Concepts

ConceptDescription
ModuleCollection of related definitions
SignatureModule interface specification
StructureModule implementation
FunctorModule-level function
SealingHide implementation behind signature
ImportUse definitions from another module

Tips

  • Use signatures for abstraction
  • Seal modules to hide implementation
  • Use functors for generic libraries
  • Consider cyclic dependencies carefully
  • Separate interface from implementation

Common Use Cases

  • Large-scale software organization
  • Library design
  • Namespace management
  • Information hiding
  • Dependency injection via functors

Related Skills

  • type-class-implementer - Alternative abstraction mechanism
  • ffi-designer - Foreign function interface
  • type-checker-generator - Type checking for modules

Canonical References

ReferenceWhy It Matters
MacQueen "Modules for Standard ML"Original ML modules
Leroy "Manifest types, modules, and separate compilation"OCaml modules
Dreyer "Understanding and Evolving ML Modules"Modern treatment

Tradeoffs and Limitations

Approach Tradeoffs

ApproachProsCons
Simple modulesEasy to implementLimited abstraction
ML-stylePowerful abstractionComplex
Mixins/TraitsComposableNo sealing

When NOT to Use This Skill

  • Small single-file programs
  • When simple imports suffice
  • Prototype/experimental code

Limitations

  • Cyclic dependencies are tricky
  • Higher-order modules are complex
  • Type abstraction can be limited

Assessment Criteria

A high-quality implementation should have:

CriterionWhat to Look For
EncapsulationHides implementation
NamespaceManages names properly
DependenciesHandles imports correctly
AbstractionSupports signatures

Quality Indicators

✅ Good: Full encapsulation, proper namespacing, functor support ⚠️ Warning: Leaky abstraction, complex dependency handling ❌ Bad: No encapsulation, namespace pollution

Research Tools & Artifacts

Real-world module systems:

ToolWhy It Matters
OCaml modulesFull-featured modules
ML signaturesML module system
Rust modulesSimple module system
Java modules (JDK 9)Java module system

Key Systems

  • GHC Haskell: Type-based modules
  • Dune: OCaml build system

Research Frontiers

Current module research:

DirectionKey PapersChallenge
Hierarchical"Hierarchical Modules"Scale
Mixins"Mixins"Composition
Types"Modules as Types"Type-based

Hot Topics

  1. Wasm modules: WebAssembly modules
  2. ES modules: JavaScript modules

Implementation Pitfalls

Common module bugs:

PitfallReal ExamplePrevention
Cyclic depsCircular importsDetect cycles
Name collisionName conflictsNamespaces

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.