-- | Some internals.  They are exposed for your convenience but can change in
-- between patch releases.
module Text.Parsec.Indent.Internal
    ( Indentation (..)
    , prettyIndentation
    , prettyLine
    ) where

-- | We use our own position type that doesn't require a 'SourceName'.
data Indentation = Indentation
    { Indentation -> Int
iLine   :: !Int
    , Indentation -> Int
iColumn :: !Int
    } deriving (Int -> Indentation -> ShowS
[Indentation] -> ShowS
Indentation -> String
(Int -> Indentation -> ShowS)
-> (Indentation -> String)
-> ([Indentation] -> ShowS)
-> Show Indentation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Indentation -> ShowS
showsPrec :: Int -> Indentation -> ShowS
$cshow :: Indentation -> String
show :: Indentation -> String
$cshowList :: [Indentation] -> ShowS
showList :: [Indentation] -> ShowS
Show)

prettyIndentation :: Indentation -> String
prettyIndentation :: Indentation -> String
prettyIndentation Indentation
i = case Indentation -> Int
iColumn Indentation
i of
    Int
1 -> String
"top-level indentation"
    Int
c -> Int -> String
forall a. Show a => a -> String
show (Int
c Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-column indentation"

prettyLine :: Indentation -> String
prettyLine :: Indentation -> String
prettyLine = Int -> String
forall a. Show a => a -> String
show (Int -> String) -> (Indentation -> Int) -> Indentation -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Indentation -> Int
iLine