Skip to content

Add tutorial: Reading OCaml Errors#3583

Open
cuihtlauac wants to merge 2 commits into
mainfrom
tutorial-reading-errors
Open

Add tutorial: Reading OCaml Errors#3583
cuihtlauac wants to merge 2 commits into
mainfrom
tutorial-reading-errors

Conversation

@cuihtlauac
Copy link
Copy Markdown
Collaborator

Summary

  • New guide data/tutorials/guides/rs_03_reading_errors.md (~270 lines)
  • Teaches a systematic method for reading OCaml errors, not just a list of specific fixes
  • Covers the main error families: type mismatches, unbound identifiers, function application, pattern matching, records, modules
  • Key insight: "Unbound module" usually means missing (libraries ...) in dune, not a code error
  • Rule 1 for agents and humans: fix the first error, rebuild — later errors cascade
  • Warning reference table and -warn-error explanation
  • Step-by-step method for any unfamiliar error
  • Error examples verified against OCaml 5.x compiler output
  • Adds "reading-errors" as prerequisite to common-errors tutorial

Based on analysis of the OCaml compiler's error reporting infrastructure (typing/typecore.ml, typing/env.ml, typing/typemod.ml, utils/warnings.ml).

Test plan

  • make build succeeds
  • Review rendered page at /docs/reading-errors
  • Cross-reference from /docs/common-errors works

🤖 Generated with Claude Code

cuihtlauac and others added 2 commits March 26, 2026 10:01
New guide teaching a systematic method for reading OCaml compiler
errors, covering:

- Anatomy of an error message (location, tag, body, sub-messages)
- Rule 1: fix the first error, rebuild (later errors cascade)
- Type mismatches: reading "has type X" vs "expected Y", deciding
  which side is wrong
- Unbound identifiers: value, module, type, record field — and when
  "Unbound module" means a dune config issue, not a code error
- Function application errors: not-a-function, too many args, labels
- Pattern matching: exhaustiveness, unused cases
- Record/constructor errors: missing fields, shadowed types, mutability
- Module errors: signature mismatch, structure/functor confusion
- Key warnings table (8, 11, 16, 20, 26, 27, 32) and -warn-error
- Step-by-step method for approaching any unfamiliar error

Error examples verified against OCaml 5.x compiler output.

Also adds "reading-errors" as prerequisite to common-errors tutorial.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- MD040: Add `text` language tag to bare code blocks showing compiler error output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant