module SMR.Data.Located where
data Location
= L Int Int
deriving Show
data Located a
= LL Location Location a
deriving Show
startOfLocated :: Located a -> Location
startOfLocated (LL start _ _) = start
endOfLocated :: Located a -> Location
endOfLocated (LL _ end _) = end
valueOfLocated :: Located a -> a
valueOfLocated (LL _ _ x) = x
incCharOfLocation :: Int -> Location -> Location
incCharOfLocation n (L l c) = L l (c + n)
incLineOfLocation :: Int -> Location -> Location
incLineOfLocation n (L l _) = L (l + n) 1