Skip to content

Provide the Prim module hierarchy and desugar unary minus #89

Closed

Description

@biuld

Part of #75 (Phase 2). The last two M2 blockers, neither of which is a lowering gap.

1. The built-in Prim module hierarchy

failing/2197-shouldFail.purs and failing/2197-shouldFail2.purs both import Prim (Number) / import Prim (Boolean). We report ModuleNotFound instead of the expected ScopeConflict and UnknownName, because Prim does not exist as a source module.

purs provides Prim, Prim.Boolean, Prim.Int, Prim.Number, Prim.Row, Prim.Symbol, Prim.Ordering as compiler-provided modules. Seven passing files import Prim.Row and four import Prim.Symbol, so this is not only a failing-suite concern.

The tension to resolve: our commit 23c4fce represents primitives as constructors on the type spine rather than as a Prim module. Prim has to be provided as a module that re-exports those spine constructors, not by reintroducing a parallel primitive representation. CannotDefinePrimModules (2 corpus cases) means a user module named Prim must be rejected — so this needs a reserved-name rule too.

2. Unary minus

failing/2109-negate.purs is x = -5 annotated @shouldFailWith UnknownName. purs desugars unary minus into a call to negate, which is then an unknown name. We report nothing at all, so the case cannot agree.

Desugaring -e to negate e is a source-to-source rewrite that belongs with the other desugaring (694a3f8 lowered do to bind/discard/let). It needs negate to exist in Prelude — see Phase 3.

Also in this slice

The remaining transitive export rules, all measured M2 failures with no diagnostic today:

  • RequiredHiddenType.purs → TransitiveExportError: a type hidden by the export list.
  • TransitiveKindExport.purs → TransitiveExportError: a kind signature must be exported.
  • value-type-based transitive exports (value referenced in an exported signature).

Acceptance

Both 2197-* cases agree, 2109-negate.purs agrees, M2 reaches 70/70, and passing files importing Prim.* resolve.

Activity

  1. added
    gate:L2Blocks module, import, export and name resolution (D-04 L2)
    area:frontendFrontend: syntax, resolution, kinds, types, classes
    on Oct 1, 2026
  2. biuld commented on Oct 2, 2026

    @biuld
    OwnerAuthor

    Verified on master 1693408 after PR #112 and the subsequent Phase 2 integration. Fresh annotations L2 scoreboard: 70/72 overall; the only mismatches are #90 instance duplicate/orphan declarations. All relevant #89 groups agree: ScopeConflict 6/6, UnknownName 22/22, TransitiveExportError 10/10. cargo test -p psrs-resolve passed 36/36, covering shared primitive identities, official child modules, reserved namespace and ordinary negate lookup. The Wasmtime-required unary-minus execution test passed; primitive class kind schemes and inferred RequiredHiddenType tests passed; the official TransitiveKindExport fixture reports TransitiveExportError. Prim.undefined and primitive class entailment remain separately tracked in D-04 and do not narrow or block this resolved module/negate scope. Corpus cases retains the existing historical recovery cohort (21); no replacement count is inferred from unrelated current failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:frontendFrontend: syntax, resolution, kinds, types, classesenhancementNew feature or requestgate:L2Blocks module, import, export and name resolution (D-04 L2)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions