Add PrettyPrinter That Returns Both Errors & Text #351
No reviewers
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#351
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "prikhi/add-alternative-coreio"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Hi! Currently
haskell-language-server
usesparsePrintModule
in it's brittany plugin to format source code.This works well unless the source code causes brittany to throw warnings. See https://github.com/haskell/haskell-language-server/issues/2005
I added a new
pPrintText
function theBrittany.Main
module, that emulates thecoreIO
function but only relies on aConfig
and the inputText
, & returns the list of warnings/errors & either the original or formatted text.This is pretty hacky, lots of code is copy-pasted & trimmed down from the stuff in
coreIO
. Not sure ifMain
is the correct place for this, ifpPrintText
is a decent name for this, or if I should refactor a bit to reduce duplication. Feedback welcome & feel free to just toss this away and do it correctly 😉.It would be great if we could get a new release pushed after this sort of functionality is added - it'd mean we can bring back HLS auto-brittany-formatting to projects that heavily use constructs that cause brittany to raise warnings(like
TypeOperators
).Commit message follows.
Add a new
pPrintText
function to the Brittany.Main module that behavessimilarly to the
coreIO
function, but instead only take a config &input string & always returns a list of errors & either the unaltered or
the pretty printed text.
This new function will always check the generated text & ignores all
tracing and printing to stdout.
This a useful function for utility programs, like haskell-language-server,
that want to feed text to brittany & manipulate the output.
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.