Skip to content

Fixity resolution enhancement #4

@niklasbroberg

Description

@niklasbroberg
Member

Originally requested by @ndmitchell, two related improvements:

  1. If a parse results in a fixity error it should be reported through ParseError, not by raising error.
  2. 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.

Activity

robinp

robinp commented on Aug 30, 2013

@robinp

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

robinp commented on Sep 1, 2013

@robinp

Ignore previous comment, just found that can supply fixities in ParseMode.

mgsloan

mgsloan commented on Sep 20, 2013

@mgsloan
Contributor

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 define fail, so it's just error.

I'm going to make a pull request to both remove the SrcSpanInfo and add a definition for fail.

ndmitchell

ndmitchell commented on Sep 24, 2013

@ndmitchell
Contributor

@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

mgsloan commented on Sep 24, 2013

@mgsloan
Contributor

@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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mgsloan@robinp@niklasbroberg@ndmitchell

        Issue actions

          Fixity resolution enhancement · Issue #4 · haskell-suite/haskell-src-exts