{-# OPTIONS_GHC -Wno-orphans #-}
module FreeC.Frontend.Haskell.SrcSpanConverter ( ConvertibleSrcSpan(..) ) where
import Control.Monad ( join )
import qualified Language.Haskell.Exts.SrcLoc as HSE
import FreeC.IR.SrcSpan
instance ConvertibleSrcSpan HSE.SrcSpan where
convertSrcSpan srcFileMap srcSpan = SrcSpan
{ srcSpanFile = lookupSrcFile (HSE.srcSpanFilename srcSpan)
srcFileMap
, srcSpanStartLine = HSE.srcSpanStartLine srcSpan
, srcSpanStartColumn = HSE.srcSpanStartColumn srcSpan
, srcSpanEndLine = HSE.srcSpanEndLine srcSpan
, srcSpanEndColumn = HSE.srcSpanEndColumn srcSpan
}
instance ConvertibleSrcSpan HSE.SrcSpanInfo where
convertSrcSpan srcFileMap = convertSrcSpan srcFileMap . HSE.srcInfoSpan
instance ConvertibleSrcSpan HSE.SrcLoc where
convertSrcSpan srcFileMap = convertSrcSpan srcFileMap . join HSE.mkSrcSpan