existential-types
Skill17 starsChanged 9 months agoApache-2.0View on GitHub
Implement existential types for data abstraction and hiding type information.
In this repository98 other files it gives its agents.
- abstract-interpretation-engineSkill
- abstract-machineSkill
- acsl-annotation-assistantSkill
- actor-model-implementerSkill
- algebraic-effectsSkill
- alias-and-points-to-analysisSkill
- axiomatic-semanticsSkill
- bidirectional-type-checkingSkill
- bisimulation-checkerSkill
- capability-systemSkill
- closure-converterSkill
- common-subexpression-eliminatorSkill
- concurrency-verifierSkill
- constant-propagation-passSkill
- contextual-equivalenceSkill
- control-flow-analysisSkill
- coq-proof-assistantSkill
- cps-transformerSkill
- dafny-verifierSkill
- dataflow-analysis-frameworkSkill
- dead-code-eliminatorSkill
- defunctionalizationSkill
- denotational-semantics-builderSkill
- dependent-type-implementerSkill
- dsl-embeddingSkill
- effect-handlers-implementerSkill
- effect-systemSkill
- effect-type-systemSkill
- escape-analysisSkill
- ffi-designerSkill
- fuzzer-generatorSkill
- gadt-implementerSkill
- garbage-collector-implementerSkill
- graalvm-truffle-implementerSkill
- gradual-typing-implementerSkill
- higher-order-abstract-syntaxSkill
- hoare-logic-verifierSkill
- incremental-computationSkill
- information-flow-analyzerSkill
- inline-expanderSkill
- interprocedural-analysisSkill
- invariant-generatorSkill
- jit-compiler-builderSkill
- lambda-calculus-interpreterSkill
- language-server-protocolSkill
- lean-proverSkill
- lexer-generatorSkill
- linear-type-implementerSkill
- liveness-analysisSkill
- llvm-backend-generatorSkill
- lock-free-data-structureSkill
- loop-optimizerSkill
- loop-termination-proverSkill
- macro-expanderSkill
- memory-allocatorSkill
- message-passing-systemSkill
- mlir-dialect-designerSkill
- model-checkerSkill
- module-systemSkill
- monad-transformerSkill
- The first 60 shown.
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
- Distinctive: line 28
Type Erasure: Remove type information at boundaries
- Distinctive: line 43
Use GADTs for existential types in Haskell
- Distinctive: line 47
Use continuation-passing for rank-2 types
- Distinctive: line 84
When concrete types are known (use direct types)
- Distinctive: line 86
When performance is critical (boxing overhead)
≈ “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.
Files
Existential Types
Existential types (∃α.τ) hide a type variable within a type, enabling data abstraction and the creation of heterogeneous collections. They are the dual of universal types (∀α.τ) in System F.
When to Use This Skill
- Implementing abstract data types (ADTs)
- Creating heterogeneous collections
- Building type-erased interfaces
- Implementing dynamic dispatch patterns
- Hiding implementation details
What This Skill Does
- Existential Quantification: Hide type variables in data types
- Type Abstraction: Expose operations without revealing implementation type
- Witness Types: Package a type with operations on that type
- Type Erasure: Remove type information at boundaries
- Dynamic Typing: Recover type information when needed
Key Concepts
| Concept | Description |
| Existential Quantification | ∃α.τ - there exists some type α such that τ |
| Type Hiding | Internal type not exposed to external observers |
| Package | Value bundled with operations |
| Abstract Type | Type known only by its operations |
| Dual of Universal | ∃α.τ ≈ ∀β.(∀α.τ→β)→β |
Tips
- Use GADTs for existential types in Haskell
- Existentials correspond to interfaces/protocols in OOP
- Think of them as "some type T, we don't know which"
- Combine with type classes for operation bundles
- Use continuation-passing for rank-2 types
Common Use Cases
- Abstract data types (stacks, queues, maps)
- Type-erased callbacks and handlers
- Heterogeneous collections
- State machines with hidden state
- Effect handlers
Related Skills
system-f- Universal quantification (∀)gadt-implementer- GADTs for existentialsmodule-system- ML modules for abstractiontype-class-implementer- Type classes for operations
Canonical References
| Reference | Why It Matters |
| Mitchell, Plotkin "Abstract types have existential type" (1988) | Classic paper |
| Pierce "Types and Programming Languages" Ch. 24 | Textbook treatment |
| GHC User's Guide "ExistentialQuantification" | Practical usage |
Tradeoffs and Limitations
Approach Tradeoffs
| Approach | Pros | Cons |
| GADT syntax | Clean, integrated | GHC specific |
| Explicit forall | Standard Haskell | More verbose |
| newtype wrapper | Simple | Limited flexibility |
When NOT to Use This Skill
- When concrete types are known (use direct types)
- For simple polymorphism (use
system-f) - When performance is critical (boxing overhead)
Limitations
- Cannot pattern match on hidden type
- Some runtime overhead for packaging
- Type inference is limited
Assessment Criteria
A high-quality implementation should have:
| Criterion | What to Look For |
| Type Safety | Hidden type cannot escape its scope |
| Abstraction | Implementation details are hidden |
| Operations | Packaged with necessary operations |
| Composition | Can combine existential packages |
Quality Indicators
✅ Good: Clean abstraction, well-defined operations, type-safe interface ⚠️ Warning: Escapes existential scope, exposes hidden type ❌ Bad: No real abstraction, just wrapping values
Research Tools & Artifacts
Existential types in:
| Tool | Language | What to Learn |
| GHC | Haskell | Implementation |
| OCaml | OCaml | Objects |
Research Frontiers
1. Dynamic Types
- Approach: Type erasure
Implementation Pitfalls
| Pitfall | Real Consequence | Solution |
| Type escape | Violates abstraction | Scope tracking |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

