Review Assignment Due Date ·
Open in Codespaces
Miranda Prelude Helper
A VS Code extension that provides inline documentation on hover for the
functions and operators of the Miranda
standard environment.
When you hover over a standard-environment identifier in a .m file, the
extension shows a tooltip with:
- the type signature (rendered as a code block), and
- a short description sourced from Miranda's own
stdenv.m.
No Miranda compiler (mira) is required — all documentation is static and
loaded in memory.
Features
- Hover documentation for the exported functions of the Miranda standard
environment (
abs, map, foldr, take, sort, zip2, …).
- Operator documentation for the common prelude operators:
# (length),
++ (append), -- (list difference), ! (subscript) and . (composition).
- Correctly recognizes Miranda identifiers, including primed names such as
f'.
- Registers the
miranda language id for the .m file extension.
How it works
The documentation dictionary in src/prelude.ts is
auto-generated from the literate-style standard environment file
miralib/stdenv.m by the parser in
scripts/generate-prelude.js. The parser reads
each > name :: type signature line and pairs it with the prose paragraph that
describes it.
Only stdenv.m is used. miralib/prelude contains internal system
mechanisms that are not in scope for user code, and is deliberately ignored.
The prelude operators (built into Miranda's syntax rather than defined in
stdenv.m) are curated by hand in src/operators.ts.
The lookup itself is a pure function in src/lookup.ts
(lookup(word) -> entry | undefined), which keeps it independent of VS Code and
easy to unit-test. The hover provider is wired up in
src/extension.ts.
Trying it out
Open examples/example.m and hover over the highlighted
names and operators. See CONTRIBUTING.md for how to launch the
extension in the VS Code Extension Development Host.
License
MIT.