-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Data types for managing source code locations. -- -- Data types for managing source code locations. @package srcloc @version 0.3.0 module Data.Loc -- | Position type. data Pos -- | Source file name, line, column, and character offset Pos :: !String -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Pos -- | Position file. posFile :: Pos -> String -- | Position line. posLine :: Pos -> Int -- | Position column. posCol :: Pos -> Int -- | Position character offset. posCoff :: Pos -> Int startPos :: String -> Pos linePos :: String -> Int -> Pos advancePos :: Pos -> Char -> Pos -- | Location type, consisting of a beginning position and an end position. data Loc NoLoc :: Loc -- | Beginning and end positions Loc :: {-# UNPACK #-} !Pos -> {-# UNPACK #-} !Pos -> Loc -- | Starting position of the location. locStart :: Loc -> Loc -- | Ending position of the location. locEnd :: Loc -> Loc -- | Merge the locations of two Located values. (<-->) :: (Located a, Located b) => a -> b -> Loc -- | Source location type. Source location are all equal, which allows AST -- nodes to be compared modulo location information. newtype SrcLoc SrcLoc :: Loc -> SrcLoc -- | The SrcLoc of a Located value. srclocOf :: Located a => a -> SrcLoc -- | A SrcLoc with (minimal) span that includes two Located -- values. srcspan :: (Located a, Located b) => a -> b -> SrcLoc -- | Locations class IsLocation a where fromPos p = fromLoc (Loc p p) fromLoc :: IsLocation a => Loc -> a fromPos :: IsLocation a => Pos -> a -- | No location. noLoc :: IsLocation a => a -- | Located values have a location. class Located a where locOfList xs = mconcat (map locOf xs) locOf :: Located a => a -> Loc locOfList :: Located a => [a] -> Loc -- | Values that can be relocated class Relocatable a reloc :: Relocatable a => Loc -> a -> a -- | An 'L a' is an a with an associated Loc, but this -- location is ignored when performing comparisons. data L a L :: Loc -> a -> L a unLoc :: L a -> a instance Typeable Pos instance Typeable Loc instance Typeable SrcLoc instance Eq Pos instance Show Pos instance Data Pos instance Eq Loc instance Show Loc instance Data Loc instance Data SrcLoc instance Relocatable (L a) instance Located (L a) instance Show x => Show (L x) instance Ord x => Ord (L x) instance Eq x => Eq (L x) instance Located SrcLoc instance Located Loc instance Located Pos instance Located a => Located (Maybe a) instance Located a => Located [a] instance IsLocation SrcLoc instance IsLocation Loc instance Ord SrcLoc instance Eq SrcLoc instance Monoid Loc instance Ord Pos