1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Text.RE.ZeInternals.Types.LineNo where
-- | our line numbers are of the proper zero-based kind
newtype LineNo =
ZeroBasedLineNo { getZeroBasedLineNo :: Int }
deriving (Show,Enum)
-- | the first line in a file
firstLine :: LineNo
firstLine = ZeroBasedLineNo 0
-- | extract a conventional 1-based line number
getLineNo :: LineNo -> Int
getLineNo = succ . getZeroBasedLineNo
-- | inject a conventional 1-based line number
lineNo :: Int -> LineNo
lineNo = ZeroBasedLineNo . pred
|