SrcLoc.hs 835 Bytes
Newer Older
1
{-# LANGUAGE RecordWildCards #-}
2 3

-- | @since 4.8.2.0
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
module GHC.SrcLoc
  ( SrcLoc
  , srcLocPackage
  , srcLocModule
  , srcLocFile
  , srcLocStartLine
  , srcLocStartCol
  , srcLocEndLine
  , srcLocEndCol

  -- * Pretty printing
  , showSrcLoc
  ) where

-- | A single location in the source code.
19 20
--
-- @since 4.8.2.0
21 22 23 24 25 26 27 28 29 30
data SrcLoc = SrcLoc
  { srcLocPackage   :: String
  , srcLocModule    :: String
  , srcLocFile      :: String
  , srcLocStartLine :: Int
  , srcLocStartCol  :: Int
  , srcLocEndLine   :: Int
  , srcLocEndCol    :: Int
  } deriving (Show, Eq)

31 32 33
-- | Pretty print 'SrcLoc'
--
-- @since 4.8.2.0
34 35 36 37 38 39 40
showSrcLoc :: SrcLoc -> String
showSrcLoc SrcLoc {..}
  = concat [ srcLocFile, ":"
           , show srcLocStartLine, ":"
           , show srcLocStartCol, " in "
           , srcLocPackage, ":", srcLocModule
           ]