-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Labels
Description
Originally requested by @ndmitchell, two related improvements:
- If a parse results in a fixity error it should be reported through ParseError, not by raising error.
- The applyFixities function is very limited. A better signature would be:
applyFixities :: a -> ([FixityError],a)
Now when there is a fixity error you get back a list of the errors, and a revised document with as many fixities resolved as possible. This would be particularly useful for HLint: http://code.google.com/p/ndmitchell/issues/detail?id=302
And more generally, it should suit any user of HSE. With a simple FixityError -> ParseError
function the apply fixities could easily be reused for the main parsing.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
robinp commentedon Aug 30, 2013
It would be nice if the applyFixities could also avoid the "ambigous fixities" - so not just retroactively modify a successful AST, but prevent generating the AST from failing at the first place. For example an imported module defines the (otherwise ambigous) fixities - HSE has no way knowing about this, but the client (haskell-names for example) can supply the information.
robinp commentedon Sep 1, 2013
Ignore previous comment, just found that can supply fixities in ParseMode.
mgsloan commentedon Sep 20, 2013
We've run into this issue a number of times, when directly using haskell-src-exts for the FP Haskell Center, and also when calling hlint.
applyFixities
actually has a monad in its type just to be able to call "fail". However,ParseResult
's monad instance does not definefail
, so it's justerror
.I'm going to make a pull request to both remove the
SrcSpanInfo
and add a definition forfail
.Make 'fail' report an error in 'ParseResult' (refs haskell-suite#4)
Make 'AppFixity' class not require a (* -> *) parameter applied to Sr…
Add an 'AppFixity' instance for lists (refs haskell-suite#4)
Add an 'AppFixity' instance for lists (refs haskell-suite#4)
Add an 'AppFixity' instance for lists (refs haskell-suite#4)
Add an 'AppFixity' instance for lists (refs haskell-suite#4)
ndmitchell commentedon Sep 24, 2013
@mgsloan How do you run into it with HLint? HLint is meant to try again if it fails due to fixities with no fixity resolution, and then goes back and does something custom. Having a standard supported solution would be very useful, but I don't think you should see any big problems in HLint at the moment.
mgsloan commentedon Sep 24, 2013
@ndmitchell Ahh, you're right - I misremembered that. I think it was an issue in some other usage of HSE (parsing module names, import lists).
This bug currently also affects fay, and really anyone that uses the default parse mode - https://github.com/faylang/fay/blob/master/src/Fay/Compiler/Misc.hs#L325. It was just due to a missing
fail = ParseFailed noLoc
in its monad instance.Make 'AppFixity' class not require a (* -> *) parameter applied to Sr…
Make 'fail' report an error in 'ParseResult' (refs haskell-suite#4)
Make 'AppFixity' class not require a (* -> *) parameter applied to Sr…
Make 'fail' report an error in 'ParseResult' (refs #4)
Make 'AppFixity' class not require a (* -> *) parameter applied to Sr…
Make 'fail' report an error in 'ParseResult' (refs #4)