module Data.Loc.Loc
( Loc,
loc,
origin,
line,
column,
locShowsPrec,
locReadPrec,
)
where
import Data.Loc.Internal.Prelude
import Data.Loc.Pos (Column, Line)
import Integer.Positive (Positive)
data Loc = Loc
{ Loc -> Line
line :: Line,
Loc -> Column
column :: Column
}
deriving (Loc -> Loc -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Loc -> Loc -> Bool
$c/= :: Loc -> Loc -> Bool
== :: Loc -> Loc -> Bool
$c== :: Loc -> Loc -> Bool
Eq, Eq Loc
Loc -> Loc -> Bool
Loc -> Loc -> Ordering
Loc -> Loc -> Loc
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Loc -> Loc -> Loc
$cmin :: Loc -> Loc -> Loc
max :: Loc -> Loc -> Loc
$cmax :: Loc -> Loc -> Loc
>= :: Loc -> Loc -> Bool
$c>= :: Loc -> Loc -> Bool
> :: Loc -> Loc -> Bool
$c> :: Loc -> Loc -> Bool
<= :: Loc -> Loc -> Bool
$c<= :: Loc -> Loc -> Bool
< :: Loc -> Loc -> Bool
$c< :: Loc -> Loc -> Bool
compare :: Loc -> Loc -> Ordering
$ccompare :: Loc -> Loc -> Ordering
Ord)
instance Show Loc where
showsPrec :: Int -> Loc -> ShowS
showsPrec = Int -> Loc -> ShowS
locShowsPrec
instance Read Loc where
readPrec :: ReadPrec Loc
readPrec = ReadPrec Loc
locReadPrec
locShowsPrec :: Int -> Loc -> ShowS
locShowsPrec :: Int -> Loc -> ShowS
locShowsPrec Int
_ (Loc Line
l Column
c) =
forall a. Show a => a -> ShowS
shows Line
l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
":"
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> ShowS
shows Column
c
locReadPrec :: ReadPrec Loc
locReadPrec :: ReadPrec Loc
locReadPrec =
Line -> Column -> Loc
Loc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Read a => ReadPrec a
readPrec @Positive)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ReadPrec ()
readPrecChar Char
':'
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Read a => ReadPrec a
readPrec @Positive)
loc :: Line -> Column -> Loc
loc :: Line -> Column -> Loc
loc = Line -> Column -> Loc
Loc
origin :: Loc
origin :: Loc
origin = Line -> Column -> Loc
loc Line
1 Column
1