    {-# LANGUAGE GeneralizedNewtypeDeriving #-}

    module Text.RE.ZeInternals.Types.LineNo where

    -- | our line numbers are of the proper zero-based kind
    newtype LineNo =
        ZeroBasedLineNo { LineNo -> Int
    getZeroBasedLineNo :: Int }
      deriving (Int -> LineNo -> ShowS
    [LineNo] -> ShowS
    LineNo -> String
    (Int -> LineNo -> ShowS)
    -> (LineNo -> String) -> ([LineNo] -> ShowS) -> Show LineNo
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> LineNo -> ShowS
    showsPrec :: Int -> LineNo -> ShowS
    $cshow :: LineNo -> String
    show :: LineNo -> String
    $cshowList :: [LineNo] -> ShowS
    showList :: [LineNo] -> ShowS
    Show,Int -> LineNo
    LineNo -> Int
    LineNo -> [LineNo]
    LineNo -> LineNo
    LineNo -> LineNo -> [LineNo]
    LineNo -> LineNo -> LineNo -> [LineNo]
    (LineNo -> LineNo)
    -> (LineNo -> LineNo)
    -> (Int -> LineNo)
    -> (LineNo -> Int)
    -> (LineNo -> [LineNo])
    -> (LineNo -> LineNo -> [LineNo])
    -> (LineNo -> LineNo -> [LineNo])
    -> (LineNo -> LineNo -> LineNo -> [LineNo])
    -> Enum LineNo
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: LineNo -> LineNo
    succ :: LineNo -> LineNo
    $cpred :: LineNo -> LineNo
    pred :: LineNo -> LineNo
    $ctoEnum :: Int -> LineNo
    toEnum :: Int -> LineNo
    $cfromEnum :: LineNo -> Int
    fromEnum :: LineNo -> Int
    $cenumFrom :: LineNo -> [LineNo]
    enumFrom :: LineNo -> [LineNo]
    $cenumFromThen :: LineNo -> LineNo -> [LineNo]
    enumFromThen :: LineNo -> LineNo -> [LineNo]
    $cenumFromTo :: LineNo -> LineNo -> [LineNo]
    enumFromTo :: LineNo -> LineNo -> [LineNo]
    $cenumFromThenTo :: LineNo -> LineNo -> LineNo -> [LineNo]
    enumFromThenTo :: LineNo -> LineNo -> LineNo -> [LineNo]
    Enum)

    -- | the first line in a file
    firstLine :: LineNo
    firstLine :: LineNo
    firstLine = Int -> LineNo
    ZeroBasedLineNo Int
    0

    -- | extract a conventional 1-based line number
    getLineNo :: LineNo -> Int
    getLineNo :: LineNo -> Int
    getLineNo = Int -> Int
    forall a. Enum a => a -> a
    succ (Int -> Int) -> (LineNo -> Int) -> LineNo -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LineNo -> Int
    getZeroBasedLineNo

    -- | inject a conventional 1-based line number
    lineNo :: Int -> LineNo
    lineNo :: Int -> LineNo
    lineNo = Int -> LineNo
    ZeroBasedLineNo (Int -> LineNo) -> (Int -> Int) -> Int -> LineNo
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Int
    forall a. Enum a => a -> a
    pred