module BNFC.Types.Position where

import BNFC.Prelude

data WithPosition a = WithPosition
  { WithPosition a -> Position
wpPos   :: !Position
  , WithPosition a -> a
wpThing :: a
  } deriving (WithPosition a -> WithPosition a -> Bool
(WithPosition a -> WithPosition a -> Bool)
-> (WithPosition a -> WithPosition a -> Bool)
-> Eq (WithPosition a)
forall a. Eq a => WithPosition a -> WithPosition a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithPosition a -> WithPosition a -> Bool
$c/= :: forall a. Eq a => WithPosition a -> WithPosition a -> Bool
== :: WithPosition a -> WithPosition a -> Bool
$c== :: forall a. Eq a => WithPosition a -> WithPosition a -> Bool
Eq, Eq (WithPosition a)
Eq (WithPosition a)
-> (WithPosition a -> WithPosition a -> Ordering)
-> (WithPosition a -> WithPosition a -> Bool)
-> (WithPosition a -> WithPosition a -> Bool)
-> (WithPosition a -> WithPosition a -> Bool)
-> (WithPosition a -> WithPosition a -> Bool)
-> (WithPosition a -> WithPosition a -> WithPosition a)
-> (WithPosition a -> WithPosition a -> WithPosition a)
-> Ord (WithPosition a)
WithPosition a -> WithPosition a -> Bool
WithPosition a -> WithPosition a -> Ordering
WithPosition a -> WithPosition a -> WithPosition a
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
forall a. Ord a => Eq (WithPosition a)
forall a. Ord a => WithPosition a -> WithPosition a -> Bool
forall a. Ord a => WithPosition a -> WithPosition a -> Ordering
forall a.
Ord a =>
WithPosition a -> WithPosition a -> WithPosition a
min :: WithPosition a -> WithPosition a -> WithPosition a
$cmin :: forall a.
Ord a =>
WithPosition a -> WithPosition a -> WithPosition a
max :: WithPosition a -> WithPosition a -> WithPosition a
$cmax :: forall a.
Ord a =>
WithPosition a -> WithPosition a -> WithPosition a
>= :: WithPosition a -> WithPosition a -> Bool
$c>= :: forall a. Ord a => WithPosition a -> WithPosition a -> Bool
> :: WithPosition a -> WithPosition a -> Bool
$c> :: forall a. Ord a => WithPosition a -> WithPosition a -> Bool
<= :: WithPosition a -> WithPosition a -> Bool
$c<= :: forall a. Ord a => WithPosition a -> WithPosition a -> Bool
< :: WithPosition a -> WithPosition a -> Bool
$c< :: forall a. Ord a => WithPosition a -> WithPosition a -> Bool
compare :: WithPosition a -> WithPosition a -> Ordering
$ccompare :: forall a. Ord a => WithPosition a -> WithPosition a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (WithPosition a)
Ord, Int -> WithPosition a -> ShowS
[WithPosition a] -> ShowS
WithPosition a -> String
(Int -> WithPosition a -> ShowS)
-> (WithPosition a -> String)
-> ([WithPosition a] -> ShowS)
-> Show (WithPosition a)
forall a. Show a => Int -> WithPosition a -> ShowS
forall a. Show a => [WithPosition a] -> ShowS
forall a. Show a => WithPosition a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithPosition a] -> ShowS
$cshowList :: forall a. Show a => [WithPosition a] -> ShowS
show :: WithPosition a -> String
$cshow :: forall a. Show a => WithPosition a -> String
showsPrec :: Int -> WithPosition a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> WithPosition a -> ShowS
Show, a -> WithPosition b -> WithPosition a
(a -> b) -> WithPosition a -> WithPosition b
(forall a b. (a -> b) -> WithPosition a -> WithPosition b)
-> (forall a b. a -> WithPosition b -> WithPosition a)
-> Functor WithPosition
forall a b. a -> WithPosition b -> WithPosition a
forall a b. (a -> b) -> WithPosition a -> WithPosition b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> WithPosition b -> WithPosition a
$c<$ :: forall a b. a -> WithPosition b -> WithPosition a
fmap :: (a -> b) -> WithPosition a -> WithPosition b
$cfmap :: forall a b. (a -> b) -> WithPosition a -> WithPosition b
Functor, WithPosition a -> Bool
(a -> m) -> WithPosition a -> m
(a -> b -> b) -> b -> WithPosition a -> b
(forall m. Monoid m => WithPosition m -> m)
-> (forall m a. Monoid m => (a -> m) -> WithPosition a -> m)
-> (forall m a. Monoid m => (a -> m) -> WithPosition a -> m)
-> (forall a b. (a -> b -> b) -> b -> WithPosition a -> b)
-> (forall a b. (a -> b -> b) -> b -> WithPosition a -> b)
-> (forall b a. (b -> a -> b) -> b -> WithPosition a -> b)
-> (forall b a. (b -> a -> b) -> b -> WithPosition a -> b)
-> (forall a. (a -> a -> a) -> WithPosition a -> a)
-> (forall a. (a -> a -> a) -> WithPosition a -> a)
-> (forall a. WithPosition a -> [a])
-> (forall a. WithPosition a -> Bool)
-> (forall a. WithPosition a -> Int)
-> (forall a. Eq a => a -> WithPosition a -> Bool)
-> (forall a. Ord a => WithPosition a -> a)
-> (forall a. Ord a => WithPosition a -> a)
-> (forall a. Num a => WithPosition a -> a)
-> (forall a. Num a => WithPosition a -> a)
-> Foldable WithPosition
forall a. Eq a => a -> WithPosition a -> Bool
forall a. Num a => WithPosition a -> a
forall a. Ord a => WithPosition a -> a
forall m. Monoid m => WithPosition m -> m
forall a. WithPosition a -> Bool
forall a. WithPosition a -> Int
forall a. WithPosition a -> [a]
forall a. (a -> a -> a) -> WithPosition a -> a
forall m a. Monoid m => (a -> m) -> WithPosition a -> m
forall b a. (b -> a -> b) -> b -> WithPosition a -> b
forall a b. (a -> b -> b) -> b -> WithPosition a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: WithPosition a -> a
$cproduct :: forall a. Num a => WithPosition a -> a
sum :: WithPosition a -> a
$csum :: forall a. Num a => WithPosition a -> a
minimum :: WithPosition a -> a
$cminimum :: forall a. Ord a => WithPosition a -> a
maximum :: WithPosition a -> a
$cmaximum :: forall a. Ord a => WithPosition a -> a
elem :: a -> WithPosition a -> Bool
$celem :: forall a. Eq a => a -> WithPosition a -> Bool
length :: WithPosition a -> Int
$clength :: forall a. WithPosition a -> Int
null :: WithPosition a -> Bool
$cnull :: forall a. WithPosition a -> Bool
toList :: WithPosition a -> [a]
$ctoList :: forall a. WithPosition a -> [a]
foldl1 :: (a -> a -> a) -> WithPosition a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> WithPosition a -> a
foldr1 :: (a -> a -> a) -> WithPosition a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> WithPosition a -> a
foldl' :: (b -> a -> b) -> b -> WithPosition a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> WithPosition a -> b
foldl :: (b -> a -> b) -> b -> WithPosition a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> WithPosition a -> b
foldr' :: (a -> b -> b) -> b -> WithPosition a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> WithPosition a -> b
foldr :: (a -> b -> b) -> b -> WithPosition a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> WithPosition a -> b
foldMap' :: (a -> m) -> WithPosition a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> WithPosition a -> m
foldMap :: (a -> m) -> WithPosition a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> WithPosition a -> m
fold :: WithPosition m -> m
$cfold :: forall m. Monoid m => WithPosition m -> m
Foldable, Functor WithPosition
Foldable WithPosition
Functor WithPosition
-> Foldable WithPosition
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> WithPosition a -> f (WithPosition b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    WithPosition (f a) -> f (WithPosition a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> WithPosition a -> m (WithPosition b))
-> (forall (m :: * -> *) a.
    Monad m =>
    WithPosition (m a) -> m (WithPosition a))
-> Traversable WithPosition
(a -> f b) -> WithPosition a -> f (WithPosition b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
WithPosition (m a) -> m (WithPosition a)
forall (f :: * -> *) a.
Applicative f =>
WithPosition (f a) -> f (WithPosition a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithPosition a -> m (WithPosition b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithPosition a -> f (WithPosition b)
sequence :: WithPosition (m a) -> m (WithPosition a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
WithPosition (m a) -> m (WithPosition a)
mapM :: (a -> m b) -> WithPosition a -> m (WithPosition b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithPosition a -> m (WithPosition b)
sequenceA :: WithPosition (f a) -> f (WithPosition a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
WithPosition (f a) -> f (WithPosition a)
traverse :: (a -> f b) -> WithPosition a -> f (WithPosition b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithPosition a -> f (WithPosition b)
$cp2Traversable :: Foldable WithPosition
$cp1Traversable :: Functor WithPosition
Traversable)

data WithPosition' a = WithPosition'
  { WithPosition' a -> Position'
wpPos'   :: !Position'
  , WithPosition' a -> a
wpThing' :: a
  } deriving (Int -> WithPosition' a -> ShowS
[WithPosition' a] -> ShowS
WithPosition' a -> String
(Int -> WithPosition' a -> ShowS)
-> (WithPosition' a -> String)
-> ([WithPosition' a] -> ShowS)
-> Show (WithPosition' a)
forall a. Show a => Int -> WithPosition' a -> ShowS
forall a. Show a => [WithPosition' a] -> ShowS
forall a. Show a => WithPosition' a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithPosition' a] -> ShowS
$cshowList :: forall a. Show a => [WithPosition' a] -> ShowS
show :: WithPosition' a -> String
$cshow :: forall a. Show a => WithPosition' a -> String
showsPrec :: Int -> WithPosition' a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> WithPosition' a -> ShowS
Show, a -> WithPosition' b -> WithPosition' a
(a -> b) -> WithPosition' a -> WithPosition' b
(forall a b. (a -> b) -> WithPosition' a -> WithPosition' b)
-> (forall a b. a -> WithPosition' b -> WithPosition' a)
-> Functor WithPosition'
forall a b. a -> WithPosition' b -> WithPosition' a
forall a b. (a -> b) -> WithPosition' a -> WithPosition' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> WithPosition' b -> WithPosition' a
$c<$ :: forall a b. a -> WithPosition' b -> WithPosition' a
fmap :: (a -> b) -> WithPosition' a -> WithPosition' b
$cfmap :: forall a b. (a -> b) -> WithPosition' a -> WithPosition' b
Functor, WithPosition' a -> Bool
(a -> m) -> WithPosition' a -> m
(a -> b -> b) -> b -> WithPosition' a -> b
(forall m. Monoid m => WithPosition' m -> m)
-> (forall m a. Monoid m => (a -> m) -> WithPosition' a -> m)
-> (forall m a. Monoid m => (a -> m) -> WithPosition' a -> m)
-> (forall a b. (a -> b -> b) -> b -> WithPosition' a -> b)
-> (forall a b. (a -> b -> b) -> b -> WithPosition' a -> b)
-> (forall b a. (b -> a -> b) -> b -> WithPosition' a -> b)
-> (forall b a. (b -> a -> b) -> b -> WithPosition' a -> b)
-> (forall a. (a -> a -> a) -> WithPosition' a -> a)
-> (forall a. (a -> a -> a) -> WithPosition' a -> a)
-> (forall a. WithPosition' a -> [a])
-> (forall a. WithPosition' a -> Bool)
-> (forall a. WithPosition' a -> Int)
-> (forall a. Eq a => a -> WithPosition' a -> Bool)
-> (forall a. Ord a => WithPosition' a -> a)
-> (forall a. Ord a => WithPosition' a -> a)
-> (forall a. Num a => WithPosition' a -> a)
-> (forall a. Num a => WithPosition' a -> a)
-> Foldable WithPosition'
forall a. Eq a => a -> WithPosition' a -> Bool
forall a. Num a => WithPosition' a -> a
forall a. Ord a => WithPosition' a -> a
forall m. Monoid m => WithPosition' m -> m
forall a. WithPosition' a -> Bool
forall a. WithPosition' a -> Int
forall a. WithPosition' a -> [a]
forall a. (a -> a -> a) -> WithPosition' a -> a
forall m a. Monoid m => (a -> m) -> WithPosition' a -> m
forall b a. (b -> a -> b) -> b -> WithPosition' a -> b
forall a b. (a -> b -> b) -> b -> WithPosition' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: WithPosition' a -> a
$cproduct :: forall a. Num a => WithPosition' a -> a
sum :: WithPosition' a -> a
$csum :: forall a. Num a => WithPosition' a -> a
minimum :: WithPosition' a -> a
$cminimum :: forall a. Ord a => WithPosition' a -> a
maximum :: WithPosition' a -> a
$cmaximum :: forall a. Ord a => WithPosition' a -> a
elem :: a -> WithPosition' a -> Bool
$celem :: forall a. Eq a => a -> WithPosition' a -> Bool
length :: WithPosition' a -> Int
$clength :: forall a. WithPosition' a -> Int
null :: WithPosition' a -> Bool
$cnull :: forall a. WithPosition' a -> Bool
toList :: WithPosition' a -> [a]
$ctoList :: forall a. WithPosition' a -> [a]
foldl1 :: (a -> a -> a) -> WithPosition' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> WithPosition' a -> a
foldr1 :: (a -> a -> a) -> WithPosition' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> WithPosition' a -> a
foldl' :: (b -> a -> b) -> b -> WithPosition' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> WithPosition' a -> b
foldl :: (b -> a -> b) -> b -> WithPosition' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> WithPosition' a -> b
foldr' :: (a -> b -> b) -> b -> WithPosition' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> WithPosition' a -> b
foldr :: (a -> b -> b) -> b -> WithPosition' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> WithPosition' a -> b
foldMap' :: (a -> m) -> WithPosition' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> WithPosition' a -> m
foldMap :: (a -> m) -> WithPosition' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> WithPosition' a -> m
fold :: WithPosition' m -> m
$cfold :: forall m. Monoid m => WithPosition' m -> m
Foldable, Functor WithPosition'
Foldable WithPosition'
Functor WithPosition'
-> Foldable WithPosition'
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> WithPosition' a -> f (WithPosition' b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    WithPosition' (f a) -> f (WithPosition' a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> WithPosition' a -> m (WithPosition' b))
-> (forall (m :: * -> *) a.
    Monad m =>
    WithPosition' (m a) -> m (WithPosition' a))
-> Traversable WithPosition'
(a -> f b) -> WithPosition' a -> f (WithPosition' b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
WithPosition' (m a) -> m (WithPosition' a)
forall (f :: * -> *) a.
Applicative f =>
WithPosition' (f a) -> f (WithPosition' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithPosition' a -> m (WithPosition' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithPosition' a -> f (WithPosition' b)
sequence :: WithPosition' (m a) -> m (WithPosition' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
WithPosition' (m a) -> m (WithPosition' a)
mapM :: (a -> m b) -> WithPosition' a -> m (WithPosition' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithPosition' a -> m (WithPosition' b)
sequenceA :: WithPosition' (f a) -> f (WithPosition' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
WithPosition' (f a) -> f (WithPosition' a)
traverse :: (a -> f b) -> WithPosition' a -> f (WithPosition' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithPosition' a -> f (WithPosition' b)
$cp2Traversable :: Foldable WithPosition'
$cp1Traversable :: Functor WithPosition'
Traversable)

type Position' = Maybe Position
data Position = Position
  { Position -> Int
posLine :: !Int  -- ^ Starting at line, counting from 1.  (0 for invalid line.)
  , Position -> Int
posCol  :: !Int  -- ^ Starting at column, counting from 1.  (0 for invalid column.)
  }
  deriving (Position -> Position -> Bool
(Position -> Position -> Bool)
-> (Position -> Position -> Bool) -> Eq Position
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Position -> Position -> Bool
$c/= :: Position -> Position -> Bool
== :: Position -> Position -> Bool
$c== :: Position -> Position -> Bool
Eq, Eq Position
Eq Position
-> (Position -> Position -> Ordering)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Bool)
-> (Position -> Position -> Position)
-> (Position -> Position -> Position)
-> Ord Position
Position -> Position -> Bool
Position -> Position -> Ordering
Position -> Position -> Position
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 :: Position -> Position -> Position
$cmin :: Position -> Position -> Position
max :: Position -> Position -> Position
$cmax :: Position -> Position -> Position
>= :: Position -> Position -> Bool
$c>= :: Position -> Position -> Bool
> :: Position -> Position -> Bool
$c> :: Position -> Position -> Bool
<= :: Position -> Position -> Bool
$c<= :: Position -> Position -> Bool
< :: Position -> Position -> Bool
$c< :: Position -> Position -> Bool
compare :: Position -> Position -> Ordering
$ccompare :: Position -> Position -> Ordering
$cp1Ord :: Eq Position
Ord, Int -> Position -> ShowS
[Position] -> ShowS
Position -> String
(Int -> Position -> ShowS)
-> (Position -> String) -> ([Position] -> ShowS) -> Show Position
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Position] -> ShowS
$cshowList :: [Position] -> ShowS
show :: Position -> String
$cshow :: Position -> String
showsPrec :: Int -> Position -> ShowS
$cshowsPrec :: Int -> Position -> ShowS
Show)

instance Bounded Position where
  minBound :: Position
minBound = Int -> Int -> Position
Position Int
0 Int
0
  maxBound :: Position
maxBound = Int -> Int -> Position
Position Int
forall a. Bounded a => a
maxBound Int
forall a. Bounded a => a
maxBound

-- | Something that can be parsed into a 'Position'.

class ToPosition p where
  toPosition :: p -> Position

instance ToPosition Position where
  toPosition :: Position -> Position
toPosition = Position -> Position
forall a. a -> a
id

instance ToPosition (Int, Int) where
  toPosition :: (Int, Int) -> Position
toPosition = (Int -> Int -> Position) -> (Int, Int) -> Position
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> Int -> Position
Position

-- | Something that can be parsed into a 'Position''.

class ToPosition' p where
  toPosition' :: p -> Position'

instance ToPosition' Position' where
  toPosition' :: Position' -> Position'
toPosition' = Position' -> Position'
forall a. a -> a
id

instance ToPosition' Position where
  toPosition' :: Position -> Position'
toPosition' = Position -> Position'
forall a. a -> Maybe a
Just

instance ToPosition' (Int, Int) where
  toPosition' :: (Int, Int) -> Position'
toPosition' = Position -> Position'
forall a. a -> Maybe a
Just (Position -> Position')
-> ((Int, Int) -> Position) -> (Int, Int) -> Position'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Int -> Position) -> (Int, Int) -> Position
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> Int -> Position
Position

instance ToPosition' (Maybe (Int, Int)) where
  toPosition' :: Maybe (Int, Int) -> Position'
toPosition' = ((Int, Int) -> Position) -> Maybe (Int, Int) -> Position'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Int -> Int -> Position) -> (Int, Int) -> Position
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> Int -> Position
Position)

-- Decoration instances

instance Decoration WithPosition where
  traverseF :: (a -> m b) -> WithPosition a -> m (WithPosition b)
traverseF  a -> m b
f (WithPosition Position
pos a
x) = Position -> b -> WithPosition b
forall a. Position -> a -> WithPosition a
WithPosition Position
pos (b -> WithPosition b) -> m b -> m (WithPosition b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> m b
f a
x
  traverseF2 :: (a -> m b c)
-> WithPosition a -> m (WithPosition b) (WithPosition c)
traverseF2 a -> m b c
f (WithPosition Position
pos a
x) = (b -> WithPosition b)
-> (c -> WithPosition c)
-> m b c
-> m (WithPosition b) (WithPosition c)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap (Position -> b -> WithPosition b
forall a. Position -> a -> WithPosition a
WithPosition Position
pos) (Position -> c -> WithPosition c
forall a. Position -> a -> WithPosition a
WithPosition Position
pos) (m b c -> m (WithPosition b) (WithPosition c))
-> m b c -> m (WithPosition b) (WithPosition c)
forall a b. (a -> b) -> a -> b
$ a -> m b c
f a
x

instance Decoration WithPosition' where
  traverseF :: (a -> m b) -> WithPosition' a -> m (WithPosition' b)
traverseF  a -> m b
f (WithPosition' Position'
pos a
x) = Position' -> b -> WithPosition' b
forall a. Position' -> a -> WithPosition' a
WithPosition' Position'
pos (b -> WithPosition' b) -> m b -> m (WithPosition' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> m b
f a
x
  traverseF2 :: (a -> m b c)
-> WithPosition' a -> m (WithPosition' b) (WithPosition' c)
traverseF2 a -> m b c
f (WithPosition' Position'
pos a
x) = (b -> WithPosition' b)
-> (c -> WithPosition' c)
-> m b c
-> m (WithPosition' b) (WithPosition' c)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap (Position' -> b -> WithPosition' b
forall a. Position' -> a -> WithPosition' a
WithPosition' Position'
pos) (Position' -> c -> WithPosition' c
forall a. Position' -> a -> WithPosition' a
WithPosition' Position'
pos) (m b c -> m (WithPosition' b) (WithPosition' c))
-> m b c -> m (WithPosition' b) (WithPosition' c)
forall a b. (a -> b) -> a -> b
$ a -> m b c
f a
x