Fix misleading filename docstring (empty path returns Just "", not Nothing)#3
Conversation
The docstring claimed filename returns Nothing for an empty path, but it returns (Just "") — split always yields at least one component, so the result is never Nothing. The existing test already asserts this behaviour.
There was a problem hiding this comment.
Build & Tests
Checked out claude/fix-filename-empty-doc and ran the full CI-equivalent suite locally:
carp -x test/path.carp→ 33 passed, 0 failed. Thefilename returns empty string for empty pathtest asserts(filename "") => (Just ""), confirming the documented behaviour.angler path.carp→ cleancarp-fmt --check path.carp→ cleancarp -x gendocs.carp→ clean
GitHub CI is green on both ubuntu-latest and macos-latest.
Findings
The correction is accurate. filename is (Array.last &(split p)) and split is (String.split-by p &[separator]), which always yields at least one component ([""] for the empty string), so Array.last can never observe an empty array — filename therefore never returns Nothing. The old docstring stated the exact opposite of both the implementation and the existing test; the new wording matches reality.
Optional, out of scope: because filename provably never returns Nothing, the (Maybe String) return type is wider than it needs to be — but narrowing it would be a breaking API change, and this PR rightly limits itself to fixing the docs.
Verdict: merge
A one-line doc fix replacing an incorrect statement with the real, tested behaviour; builds clean and every check passes.
The docstring for
filenamestates:But the implementation
(Array.last &(split p))returns(Just "")for anempty path:
splitalways yields at least one component, sofilenameneverreturns
Nothing. The existing testfilename returns empty string for empty pathalready asserts(filename "")=>(Just ""), contradicting the doc.This corrects the docstring to describe the real, tested behaviour. No code or
test changes.
Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.