Add flag to reverse errors in GHC/GHCi
ClosedPublic

Authored by siddhanathan on Oct 24 2015, 11:54 PM.

Details

Summary

Allow users to reverse the error list in GHC/GHCi

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
siddhanathan retitled this revision from to Add flag to reverse errors in GHC/GHCi.Oct 24 2015, 11:54 PM
siddhanathan updated this object.
siddhanathan edited the test plan for this revision. (Show Details)
siddhanathan added a reviewer: austin.
siddhanathan updated the Trac tickets for this revision.

Looks reasonable enough to me.

compiler/main/ErrUtils.hs
221

Instead of sorting the list and then reversing it, you might consider simply flipping the sort comparison,

sortMsgBag dflags = sortBy (maybeFlip $ comparing errMsgSpan) . bagToList
  where
    maybeFlip
      | fromMaybe False (reverseErrors dflags) = flip
      | otherwise                              = id
  • Flip the sort comparison for the error list
bgamari requested changes to this revision.Oct 25 2015, 9:08 AM

There are validation issues, however.

compiler/main/ErrUtils.hs
223

Use fmap here or explicitly import <$> with appropriate CPP guards for GHC 7.8 compatibility.

This revision now requires changes to proceed.Oct 25 2015, 9:08 AM
siddhanathan marked an inline comment as done.
  • Use fmap instead of the infix version
bgamari accepted this revision.Oct 26 2015, 2:40 PM

Looks good to me.

This revision is now accepted and ready to land.Oct 26 2015, 2:40 PM
This revision was automatically updated to reflect the committed changes.
thomie added inline comments.
compiler/main/DynFlags.hs
2405

Should be defFlag, since it works in both ghc and ghci.

bgamari added inline comments.Nov 1 2015, 7:14 AM
compiler/main/DynFlags.hs
2405