EPA: Simplify GHC/Parser.y comb2
This is an initial MR to iron out the concept, before applying it to the other combN variants.
Use the HasLoc
instance from Ast.hs
to allow comb2
to work with
anything with a SrcSpan
This gets rid of the custom comb2A
, comb2Al
, comb2N
functions, and
removes various reLoc
calls.
The essence of the change is
class HasLoc a where
-- ^ conveniently calculate locations for things without locations attached
getHasLoc :: a -> SrcSpan
comb2 :: (HasLoc a, HasLoc b) => a -> b -> SrcSpan
comb2 a b = a `seq` b `seq` combineHasLocs a b
combineHasLocs :: (HasLoc a, HasLoc b) => a -> b -> SrcSpan
combineHasLocs a b = combineSrcSpans (getHasLoc a) (getHasLoc b)
It requires changing the HasLoc
function from loc
to getHasLoc
, the name used can be debated, please provide alternatives.
I have also put it in the Annotate.hs
module, to go with the variants of Located
we have there for exact print annotations.