Skip to content

Split Transformer into a pure class and ProjectIn - #4

Merged
thomasjm merged 1 commit into
mainfrom
class-split
Oct 12, 2026
Merged

thomasjm merged 1 commit into
mainfrom
class-split

Conversation

@thomasjm

@thomasjm thomasjm commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Makes this repo's Transformer class match the other three, so the plumbing around it can eventually be shared.

Transformer keeps the pure methods — transformPosition, untransformPosition, unproject. ProjectIn m takes project, handleDiff, handleDiffMulti.

A single class Transformer m a does not work: the pure methods never mention m, so they become ambiguous at every call site. A fundep a -> m fixes that but pins each transformer to one monad, ruling out a mixed stack. With the split, a transformer states how much monad it needs — Monad m for pure ones, which keeps them usable at Identity, MonadIO m for ones that shell out to a parser.

getParams is gone. After Params left position mapping its only caller was unproject, which can read what it needs off the transformer value; cpp and go's implementations were fabricating a constant. unproject is now a -> Doc -> Maybe Doc with a Nothing default.

Also drops a stray comment left in Transformer.hs by the previous PR.

Needs MultiParamTypeClasses. Note project @Foo becomes project @_ @Foo, since m is the first type argument now.

@thomasjm
thomasjm force-pushed the drop-params-from-position-mapping branch from b51de9c to a85f61a Compare October 11, 2026 23:48
@thomasjm
thomasjm changed the base branch from drop-params-from-position-mapping to main October 12, 2026 00:05
@thomasjm
thomasjm merged commit 9d3ecc4 into main Oct 12, 2026
2 of 3 checks passed
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