{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Agda.Syntax.Position
(
Position
, PositionWithoutFile
, Position'(..)
, SrcFile
, positionInvariant
, startPos
, movePos
, movePosByString
, backupPos
, startPos'
, Interval
, IntervalWithoutFile
, Interval'(..)
, intervalInvariant
, posToInterval
, getIntervalFile
, iLength
, fuseIntervals
, setIntervalFile
, Range
, Range'(..)
, rangeInvariant
, consecutiveAndSeparated
, intervalsToRange
, intervalToRange
, rangeIntervals
, rangeFile
, rightMargin
, noRange
, posToRange, posToRange'
, rStart, rStart'
, rEnd, rEnd'
, rangeToInterval
, rangeToIntervalWithFile
, continuous
, continuousPerLine
, PrintRange(..)
, HasRange(..)
, SetRange(..)
, KillRange(..)
, KillRangeT
, killRangeMap
, killRange1, killRange2, killRange3, killRange4, killRange5, killRange6, killRange7
, killRange8, killRange9, killRange10, killRange11, killRange12, killRange13, killRange14
, killRange15, killRange16, killRange17, killRange18, killRange19
, withRangeOf
, fuseRange
, fuseRanges
, beginningOf
, beginningOfFile
, interleaveRanges
) where
import Prelude hiding ( null )
import Control.Monad.Writer (runWriter, tell)
import Data.Foldable (Foldable)
import qualified Data.Foldable as Fold
import Data.Function
import Data.Int
import Data.List hiding (null)
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Traversable (Traversable)
import Data.Data (Data)
import Data.Sequence (Seq)
import qualified Data.Sequence as Seq
import Data.Void
import GHC.Generics (Generic)
import Agda.Utils.FileName
import Agda.Utils.List
import qualified Agda.Utils.Maybe.Strict as Strict
import Agda.Utils.Null
import Agda.Utils.Pretty
import Agda.Utils.Impossible
data Position' a = Pn
{ Position' a -> a
srcFile :: !a
, Position' a -> Int32
posPos :: !Int32
, Position' a -> Int32
posLine :: !Int32
, Position' a -> Int32
posCol :: !Int32
}
deriving (Typeable (Position' a)
DataType
Constr
Typeable (Position' a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a))
-> (Position' a -> Constr)
-> (Position' a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Position' a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Position' a)))
-> ((forall b. Data b => b -> b) -> Position' a -> Position' a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Position' a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Position' a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a))
-> Data (Position' a)
Position' a -> DataType
Position' a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Position' a))
(forall b. Data b => b -> b) -> Position' a -> Position' a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a)
forall a. Data a => Typeable (Position' a)
forall a. Data a => Position' a -> DataType
forall a. Data a => Position' a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Position' a -> Position' a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Position' a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Position' a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Position' a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Position' a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Position' a -> u
forall u. (forall d. Data d => d -> u) -> Position' a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Position' a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Position' a))
$cPn :: Constr
$tPosition' :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
gmapMp :: (forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
gmapM :: (forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Position' a -> m (Position' a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Position' a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Position' a -> u
gmapQ :: (forall d. Data d => d -> u) -> Position' a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Position' a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Position' a -> r
gmapT :: (forall b. Data b => b -> b) -> Position' a -> Position' a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Position' a -> Position' a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Position' a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Position' a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Position' a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Position' a))
dataTypeOf :: Position' a -> DataType
$cdataTypeOf :: forall a. Data a => Position' a -> DataType
toConstr :: Position' a -> Constr
$ctoConstr :: forall a. Data a => Position' a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Position' a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Position' a -> c (Position' a)
$cp1Data :: forall a. Data a => Typeable (Position' a)
Data, a -> Position' b -> Position' a
(a -> b) -> Position' a -> Position' b
(forall a b. (a -> b) -> Position' a -> Position' b)
-> (forall a b. a -> Position' b -> Position' a)
-> Functor Position'
forall a b. a -> Position' b -> Position' a
forall a b. (a -> b) -> Position' a -> Position' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Position' b -> Position' a
$c<$ :: forall a b. a -> Position' b -> Position' a
fmap :: (a -> b) -> Position' a -> Position' b
$cfmap :: forall a b. (a -> b) -> Position' a -> Position' b
Functor, Position' a -> Bool
(a -> m) -> Position' a -> m
(a -> b -> b) -> b -> Position' a -> b
(forall m. Monoid m => Position' m -> m)
-> (forall m a. Monoid m => (a -> m) -> Position' a -> m)
-> (forall m a. Monoid m => (a -> m) -> Position' a -> m)
-> (forall a b. (a -> b -> b) -> b -> Position' a -> b)
-> (forall a b. (a -> b -> b) -> b -> Position' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Position' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Position' a -> b)
-> (forall a. (a -> a -> a) -> Position' a -> a)
-> (forall a. (a -> a -> a) -> Position' a -> a)
-> (forall a. Position' a -> [a])
-> (forall a. Position' a -> Bool)
-> (forall a. Position' a -> Int)
-> (forall a. Eq a => a -> Position' a -> Bool)
-> (forall a. Ord a => Position' a -> a)
-> (forall a. Ord a => Position' a -> a)
-> (forall a. Num a => Position' a -> a)
-> (forall a. Num a => Position' a -> a)
-> Foldable Position'
forall a. Eq a => a -> Position' a -> Bool
forall a. Num a => Position' a -> a
forall a. Ord a => Position' a -> a
forall m. Monoid m => Position' m -> m
forall a. Position' a -> Bool
forall a. Position' a -> Int
forall a. Position' a -> [a]
forall a. (a -> a -> a) -> Position' a -> a
forall m a. Monoid m => (a -> m) -> Position' a -> m
forall b a. (b -> a -> b) -> b -> Position' a -> b
forall a b. (a -> b -> b) -> b -> Position' 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 :: Position' a -> a
$cproduct :: forall a. Num a => Position' a -> a
sum :: Position' a -> a
$csum :: forall a. Num a => Position' a -> a
minimum :: Position' a -> a
$cminimum :: forall a. Ord a => Position' a -> a
maximum :: Position' a -> a
$cmaximum :: forall a. Ord a => Position' a -> a
elem :: a -> Position' a -> Bool
$celem :: forall a. Eq a => a -> Position' a -> Bool
length :: Position' a -> Int
$clength :: forall a. Position' a -> Int
null :: Position' a -> Bool
$cnull :: forall a. Position' a -> Bool
toList :: Position' a -> [a]
$ctoList :: forall a. Position' a -> [a]
foldl1 :: (a -> a -> a) -> Position' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Position' a -> a
foldr1 :: (a -> a -> a) -> Position' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Position' a -> a
foldl' :: (b -> a -> b) -> b -> Position' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Position' a -> b
foldl :: (b -> a -> b) -> b -> Position' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Position' a -> b
foldr' :: (a -> b -> b) -> b -> Position' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Position' a -> b
foldr :: (a -> b -> b) -> b -> Position' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Position' a -> b
foldMap' :: (a -> m) -> Position' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Position' a -> m
foldMap :: (a -> m) -> Position' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Position' a -> m
fold :: Position' m -> m
$cfold :: forall m. Monoid m => Position' m -> m
Foldable, Functor Position'
Foldable Position'
Functor Position'
-> Foldable Position'
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Position' a -> f (Position' b))
-> (forall (f :: * -> *) a.
Applicative f =>
Position' (f a) -> f (Position' a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Position' a -> m (Position' b))
-> (forall (m :: * -> *) a.
Monad m =>
Position' (m a) -> m (Position' a))
-> Traversable Position'
(a -> f b) -> Position' a -> f (Position' 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 =>
Position' (m a) -> m (Position' a)
forall (f :: * -> *) a.
Applicative f =>
Position' (f a) -> f (Position' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Position' a -> m (Position' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Position' a -> f (Position' b)
sequence :: Position' (m a) -> m (Position' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
Position' (m a) -> m (Position' a)
mapM :: (a -> m b) -> Position' a -> m (Position' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Position' a -> m (Position' b)
sequenceA :: Position' (f a) -> f (Position' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Position' (f a) -> f (Position' a)
traverse :: (a -> f b) -> Position' a -> f (Position' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Position' a -> f (Position' b)
$cp2Traversable :: Foldable Position'
$cp1Traversable :: Functor Position'
Traversable, (forall x. Position' a -> Rep (Position' a) x)
-> (forall x. Rep (Position' a) x -> Position' a)
-> Generic (Position' a)
forall x. Rep (Position' a) x -> Position' a
forall x. Position' a -> Rep (Position' a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Position' a) x -> Position' a
forall a x. Position' a -> Rep (Position' a) x
$cto :: forall a x. Rep (Position' a) x -> Position' a
$cfrom :: forall a x. Position' a -> Rep (Position' a) x
Generic)
positionInvariant :: Position' a -> Bool
positionInvariant :: Position' a -> Bool
positionInvariant Position' a
p =
Position' a -> Int32
forall a. Position' a -> Int32
posPos Position' a
p Int32 -> Int32 -> Bool
forall a. Ord a => a -> a -> Bool
> Int32
0 Bool -> Bool -> Bool
&& Position' a -> Int32
forall a. Position' a -> Int32
posLine Position' a
p Int32 -> Int32 -> Bool
forall a. Ord a => a -> a -> Bool
> Int32
0 Bool -> Bool -> Bool
&& Position' a -> Int32
forall a. Position' a -> Int32
posCol Position' a
p Int32 -> Int32 -> Bool
forall a. Ord a => a -> a -> Bool
> Int32
0
importantPart :: Position' a -> (a, Int32)
importantPart :: Position' a -> (a, Int32)
importantPart Position' a
p = (Position' a -> a
forall a. Position' a -> a
srcFile Position' a
p, Position' a -> Int32
forall a. Position' a -> Int32
posPos Position' a
p)
instance Eq a => Eq (Position' a) where
== :: Position' a -> Position' a -> Bool
(==) = (a, Int32) -> (a, Int32) -> Bool
forall a. Eq a => a -> a -> Bool
(==) ((a, Int32) -> (a, Int32) -> Bool)
-> (Position' a -> (a, Int32))
-> Position' a
-> Position' a
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Position' a -> (a, Int32)
forall a. Position' a -> (a, Int32)
importantPart
instance Ord a => Ord (Position' a) where
compare :: Position' a -> Position' a -> Ordering
compare = (a, Int32) -> (a, Int32) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ((a, Int32) -> (a, Int32) -> Ordering)
-> (Position' a -> (a, Int32))
-> Position' a
-> Position' a
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` Position' a -> (a, Int32)
forall a. Position' a -> (a, Int32)
importantPart
type SrcFile = Strict.Maybe AbsolutePath
type Position = Position' SrcFile
type PositionWithoutFile = Position' ()
data Interval' a = Interval { Interval' a -> Position' a
iStart, Interval' a -> Position' a
iEnd :: !(Position' a) }
deriving (Typeable (Interval' a)
DataType
Constr
Typeable (Interval' a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a))
-> (Interval' a -> Constr)
-> (Interval' a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Interval' a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Interval' a)))
-> ((forall b. Data b => b -> b) -> Interval' a -> Interval' a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Interval' a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Interval' a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a))
-> Data (Interval' a)
Interval' a -> DataType
Interval' a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Interval' a))
(forall b. Data b => b -> b) -> Interval' a -> Interval' a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a)
forall a. Data a => Typeable (Interval' a)
forall a. Data a => Interval' a -> DataType
forall a. Data a => Interval' a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Interval' a -> Interval' a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Interval' a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Interval' a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Interval' a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Interval' a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Interval' a -> u
forall u. (forall d. Data d => d -> u) -> Interval' a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Interval' a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Interval' a))
$cInterval :: Constr
$tInterval' :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
gmapMp :: (forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
gmapM :: (forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Interval' a -> m (Interval' a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Interval' a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Interval' a -> u
gmapQ :: (forall d. Data d => d -> u) -> Interval' a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Interval' a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Interval' a -> r
gmapT :: (forall b. Data b => b -> b) -> Interval' a -> Interval' a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Interval' a -> Interval' a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Interval' a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Interval' a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Interval' a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Interval' a))
dataTypeOf :: Interval' a -> DataType
$cdataTypeOf :: forall a. Data a => Interval' a -> DataType
toConstr :: Interval' a -> Constr
$ctoConstr :: forall a. Data a => Interval' a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Interval' a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Interval' a -> c (Interval' a)
$cp1Data :: forall a. Data a => Typeable (Interval' a)
Data, Interval' a -> Interval' a -> Bool
(Interval' a -> Interval' a -> Bool)
-> (Interval' a -> Interval' a -> Bool) -> Eq (Interval' a)
forall a. Eq a => Interval' a -> Interval' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Interval' a -> Interval' a -> Bool
$c/= :: forall a. Eq a => Interval' a -> Interval' a -> Bool
== :: Interval' a -> Interval' a -> Bool
$c== :: forall a. Eq a => Interval' a -> Interval' a -> Bool
Eq, Eq (Interval' a)
Eq (Interval' a)
-> (Interval' a -> Interval' a -> Ordering)
-> (Interval' a -> Interval' a -> Bool)
-> (Interval' a -> Interval' a -> Bool)
-> (Interval' a -> Interval' a -> Bool)
-> (Interval' a -> Interval' a -> Bool)
-> (Interval' a -> Interval' a -> Interval' a)
-> (Interval' a -> Interval' a -> Interval' a)
-> Ord (Interval' a)
Interval' a -> Interval' a -> Bool
Interval' a -> Interval' a -> Ordering
Interval' a -> Interval' a -> Interval' 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 (Interval' a)
forall a. Ord a => Interval' a -> Interval' a -> Bool
forall a. Ord a => Interval' a -> Interval' a -> Ordering
forall a. Ord a => Interval' a -> Interval' a -> Interval' a
min :: Interval' a -> Interval' a -> Interval' a
$cmin :: forall a. Ord a => Interval' a -> Interval' a -> Interval' a
max :: Interval' a -> Interval' a -> Interval' a
$cmax :: forall a. Ord a => Interval' a -> Interval' a -> Interval' a
>= :: Interval' a -> Interval' a -> Bool
$c>= :: forall a. Ord a => Interval' a -> Interval' a -> Bool
> :: Interval' a -> Interval' a -> Bool
$c> :: forall a. Ord a => Interval' a -> Interval' a -> Bool
<= :: Interval' a -> Interval' a -> Bool
$c<= :: forall a. Ord a => Interval' a -> Interval' a -> Bool
< :: Interval' a -> Interval' a -> Bool
$c< :: forall a. Ord a => Interval' a -> Interval' a -> Bool
compare :: Interval' a -> Interval' a -> Ordering
$ccompare :: forall a. Ord a => Interval' a -> Interval' a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Interval' a)
Ord, a -> Interval' b -> Interval' a
(a -> b) -> Interval' a -> Interval' b
(forall a b. (a -> b) -> Interval' a -> Interval' b)
-> (forall a b. a -> Interval' b -> Interval' a)
-> Functor Interval'
forall a b. a -> Interval' b -> Interval' a
forall a b. (a -> b) -> Interval' a -> Interval' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Interval' b -> Interval' a
$c<$ :: forall a b. a -> Interval' b -> Interval' a
fmap :: (a -> b) -> Interval' a -> Interval' b
$cfmap :: forall a b. (a -> b) -> Interval' a -> Interval' b
Functor, Interval' a -> Bool
(a -> m) -> Interval' a -> m
(a -> b -> b) -> b -> Interval' a -> b
(forall m. Monoid m => Interval' m -> m)
-> (forall m a. Monoid m => (a -> m) -> Interval' a -> m)
-> (forall m a. Monoid m => (a -> m) -> Interval' a -> m)
-> (forall a b. (a -> b -> b) -> b -> Interval' a -> b)
-> (forall a b. (a -> b -> b) -> b -> Interval' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Interval' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Interval' a -> b)
-> (forall a. (a -> a -> a) -> Interval' a -> a)
-> (forall a. (a -> a -> a) -> Interval' a -> a)
-> (forall a. Interval' a -> [a])
-> (forall a. Interval' a -> Bool)
-> (forall a. Interval' a -> Int)
-> (forall a. Eq a => a -> Interval' a -> Bool)
-> (forall a. Ord a => Interval' a -> a)
-> (forall a. Ord a => Interval' a -> a)
-> (forall a. Num a => Interval' a -> a)
-> (forall a. Num a => Interval' a -> a)
-> Foldable Interval'
forall a. Eq a => a -> Interval' a -> Bool
forall a. Num a => Interval' a -> a
forall a. Ord a => Interval' a -> a
forall m. Monoid m => Interval' m -> m
forall a. Interval' a -> Bool
forall a. Interval' a -> Int
forall a. Interval' a -> [a]
forall a. (a -> a -> a) -> Interval' a -> a
forall m a. Monoid m => (a -> m) -> Interval' a -> m
forall b a. (b -> a -> b) -> b -> Interval' a -> b
forall a b. (a -> b -> b) -> b -> Interval' 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 :: Interval' a -> a
$cproduct :: forall a. Num a => Interval' a -> a
sum :: Interval' a -> a
$csum :: forall a. Num a => Interval' a -> a
minimum :: Interval' a -> a
$cminimum :: forall a. Ord a => Interval' a -> a
maximum :: Interval' a -> a
$cmaximum :: forall a. Ord a => Interval' a -> a
elem :: a -> Interval' a -> Bool
$celem :: forall a. Eq a => a -> Interval' a -> Bool
length :: Interval' a -> Int
$clength :: forall a. Interval' a -> Int
null :: Interval' a -> Bool
$cnull :: forall a. Interval' a -> Bool
toList :: Interval' a -> [a]
$ctoList :: forall a. Interval' a -> [a]
foldl1 :: (a -> a -> a) -> Interval' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Interval' a -> a
foldr1 :: (a -> a -> a) -> Interval' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Interval' a -> a
foldl' :: (b -> a -> b) -> b -> Interval' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Interval' a -> b
foldl :: (b -> a -> b) -> b -> Interval' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Interval' a -> b
foldr' :: (a -> b -> b) -> b -> Interval' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Interval' a -> b
foldr :: (a -> b -> b) -> b -> Interval' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Interval' a -> b
foldMap' :: (a -> m) -> Interval' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Interval' a -> m
foldMap :: (a -> m) -> Interval' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Interval' a -> m
fold :: Interval' m -> m
$cfold :: forall m. Monoid m => Interval' m -> m
Foldable, Functor Interval'
Foldable Interval'
Functor Interval'
-> Foldable Interval'
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interval' a -> f (Interval' b))
-> (forall (f :: * -> *) a.
Applicative f =>
Interval' (f a) -> f (Interval' a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interval' a -> m (Interval' b))
-> (forall (m :: * -> *) a.
Monad m =>
Interval' (m a) -> m (Interval' a))
-> Traversable Interval'
(a -> f b) -> Interval' a -> f (Interval' 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 =>
Interval' (m a) -> m (Interval' a)
forall (f :: * -> *) a.
Applicative f =>
Interval' (f a) -> f (Interval' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interval' a -> m (Interval' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interval' a -> f (Interval' b)
sequence :: Interval' (m a) -> m (Interval' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
Interval' (m a) -> m (Interval' a)
mapM :: (a -> m b) -> Interval' a -> m (Interval' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Interval' a -> m (Interval' b)
sequenceA :: Interval' (f a) -> f (Interval' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Interval' (f a) -> f (Interval' a)
traverse :: (a -> f b) -> Interval' a -> f (Interval' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Interval' a -> f (Interval' b)
$cp2Traversable :: Foldable Interval'
$cp1Traversable :: Functor Interval'
Traversable, (forall x. Interval' a -> Rep (Interval' a) x)
-> (forall x. Rep (Interval' a) x -> Interval' a)
-> Generic (Interval' a)
forall x. Rep (Interval' a) x -> Interval' a
forall x. Interval' a -> Rep (Interval' a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Interval' a) x -> Interval' a
forall a x. Interval' a -> Rep (Interval' a) x
$cto :: forall a x. Rep (Interval' a) x -> Interval' a
$cfrom :: forall a x. Interval' a -> Rep (Interval' a) x
Generic)
type Interval = Interval' SrcFile
type IntervalWithoutFile = Interval' ()
intervalInvariant :: Ord a => Interval' a -> Bool
intervalInvariant :: Interval' a -> Bool
intervalInvariant Interval' a
i =
(Position' a -> Bool) -> [Position' a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Position' a -> Bool
forall a. Position' a -> Bool
positionInvariant [Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
i, Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
i]
Bool -> Bool -> Bool
&&
Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
i Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
<= Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
i
Bool -> Bool -> Bool
&&
Position' a -> a
forall a. Position' a -> a
srcFile (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
i) a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== Position' a -> a
forall a. Position' a -> a
srcFile (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
i)
setIntervalFile :: a -> Interval' b -> Interval' a
setIntervalFile :: a -> Interval' b -> Interval' a
setIntervalFile a
f (Interval Position' b
p1 Position' b
p2) =
Position' a -> Position' a -> Interval' a
forall a. Position' a -> Position' a -> Interval' a
Interval (Position' b
p1 { srcFile :: a
srcFile = a
f }) (Position' b
p2 { srcFile :: a
srcFile = a
f })
getIntervalFile :: Interval' a -> a
getIntervalFile :: Interval' a -> a
getIntervalFile = Position' a -> a
forall a. Position' a -> a
srcFile (Position' a -> a)
-> (Interval' a -> Position' a) -> Interval' a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart
posToInterval ::
a -> PositionWithoutFile -> PositionWithoutFile -> Interval' a
posToInterval :: a -> PositionWithoutFile -> PositionWithoutFile -> Interval' a
posToInterval a
f PositionWithoutFile
p1 PositionWithoutFile
p2 = a -> Interval' () -> Interval' a
forall a b. a -> Interval' b -> Interval' a
setIntervalFile a
f (Interval' () -> Interval' a) -> Interval' () -> Interval' a
forall a b. (a -> b) -> a -> b
$
if PositionWithoutFile
p1 PositionWithoutFile -> PositionWithoutFile -> Bool
forall a. Ord a => a -> a -> Bool
< PositionWithoutFile
p2
then PositionWithoutFile -> PositionWithoutFile -> Interval' ()
forall a. Position' a -> Position' a -> Interval' a
Interval PositionWithoutFile
p1 PositionWithoutFile
p2
else PositionWithoutFile -> PositionWithoutFile -> Interval' ()
forall a. Position' a -> Position' a -> Interval' a
Interval PositionWithoutFile
p2 PositionWithoutFile
p1
iLength :: Interval' a -> Int32
iLength :: Interval' a -> Int32
iLength Interval' a
i = Position' a -> Int32
forall a. Position' a -> Int32
posPos (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
i) Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Position' a -> Int32
forall a. Position' a -> Int32
posPos (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
i)
data Range' a
= NoRange
| Range !a (Seq IntervalWithoutFile)
deriving
(Typeable (Range' a)
DataType
Constr
Typeable (Range' a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a))
-> (Range' a -> Constr)
-> (Range' a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Range' a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Range' a)))
-> ((forall b. Data b => b -> b) -> Range' a -> Range' a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Range' a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Range' a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a))
-> Data (Range' a)
Range' a -> DataType
Range' a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Range' a))
(forall b. Data b => b -> b) -> Range' a -> Range' a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a)
forall a. Data a => Typeable (Range' a)
forall a. Data a => Range' a -> DataType
forall a. Data a => Range' a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Range' a -> Range' a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Range' a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Range' a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Range' a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Range' a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Range' a -> u
forall u. (forall d. Data d => d -> u) -> Range' a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Range' a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Range' a))
$cRange :: Constr
$cNoRange :: Constr
$tRange' :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
gmapMp :: (forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
gmapM :: (forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Range' a -> m (Range' a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Range' a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Range' a -> u
gmapQ :: (forall d. Data d => d -> u) -> Range' a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Range' a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Range' a -> r
gmapT :: (forall b. Data b => b -> b) -> Range' a -> Range' a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Range' a -> Range' a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Range' a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Range' a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Range' a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Range' a))
dataTypeOf :: Range' a -> DataType
$cdataTypeOf :: forall a. Data a => Range' a -> DataType
toConstr :: Range' a -> Constr
$ctoConstr :: forall a. Data a => Range' a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Range' a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range' a -> c (Range' a)
$cp1Data :: forall a. Data a => Typeable (Range' a)
Data, Range' a -> Range' a -> Bool
(Range' a -> Range' a -> Bool)
-> (Range' a -> Range' a -> Bool) -> Eq (Range' a)
forall a. Eq a => Range' a -> Range' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range' a -> Range' a -> Bool
$c/= :: forall a. Eq a => Range' a -> Range' a -> Bool
== :: Range' a -> Range' a -> Bool
$c== :: forall a. Eq a => Range' a -> Range' a -> Bool
Eq, Eq (Range' a)
Eq (Range' a)
-> (Range' a -> Range' a -> Ordering)
-> (Range' a -> Range' a -> Bool)
-> (Range' a -> Range' a -> Bool)
-> (Range' a -> Range' a -> Bool)
-> (Range' a -> Range' a -> Bool)
-> (Range' a -> Range' a -> Range' a)
-> (Range' a -> Range' a -> Range' a)
-> Ord (Range' a)
Range' a -> Range' a -> Bool
Range' a -> Range' a -> Ordering
Range' a -> Range' a -> Range' 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 (Range' a)
forall a. Ord a => Range' a -> Range' a -> Bool
forall a. Ord a => Range' a -> Range' a -> Ordering
forall a. Ord a => Range' a -> Range' a -> Range' a
min :: Range' a -> Range' a -> Range' a
$cmin :: forall a. Ord a => Range' a -> Range' a -> Range' a
max :: Range' a -> Range' a -> Range' a
$cmax :: forall a. Ord a => Range' a -> Range' a -> Range' a
>= :: Range' a -> Range' a -> Bool
$c>= :: forall a. Ord a => Range' a -> Range' a -> Bool
> :: Range' a -> Range' a -> Bool
$c> :: forall a. Ord a => Range' a -> Range' a -> Bool
<= :: Range' a -> Range' a -> Bool
$c<= :: forall a. Ord a => Range' a -> Range' a -> Bool
< :: Range' a -> Range' a -> Bool
$c< :: forall a. Ord a => Range' a -> Range' a -> Bool
compare :: Range' a -> Range' a -> Ordering
$ccompare :: forall a. Ord a => Range' a -> Range' a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Range' a)
Ord, a -> Range' b -> Range' a
(a -> b) -> Range' a -> Range' b
(forall a b. (a -> b) -> Range' a -> Range' b)
-> (forall a b. a -> Range' b -> Range' a) -> Functor Range'
forall a b. a -> Range' b -> Range' a
forall a b. (a -> b) -> Range' a -> Range' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Range' b -> Range' a
$c<$ :: forall a b. a -> Range' b -> Range' a
fmap :: (a -> b) -> Range' a -> Range' b
$cfmap :: forall a b. (a -> b) -> Range' a -> Range' b
Functor, Range' a -> Bool
(a -> m) -> Range' a -> m
(a -> b -> b) -> b -> Range' a -> b
(forall m. Monoid m => Range' m -> m)
-> (forall m a. Monoid m => (a -> m) -> Range' a -> m)
-> (forall m a. Monoid m => (a -> m) -> Range' a -> m)
-> (forall a b. (a -> b -> b) -> b -> Range' a -> b)
-> (forall a b. (a -> b -> b) -> b -> Range' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Range' a -> b)
-> (forall b a. (b -> a -> b) -> b -> Range' a -> b)
-> (forall a. (a -> a -> a) -> Range' a -> a)
-> (forall a. (a -> a -> a) -> Range' a -> a)
-> (forall a. Range' a -> [a])
-> (forall a. Range' a -> Bool)
-> (forall a. Range' a -> Int)
-> (forall a. Eq a => a -> Range' a -> Bool)
-> (forall a. Ord a => Range' a -> a)
-> (forall a. Ord a => Range' a -> a)
-> (forall a. Num a => Range' a -> a)
-> (forall a. Num a => Range' a -> a)
-> Foldable Range'
forall a. Eq a => a -> Range' a -> Bool
forall a. Num a => Range' a -> a
forall a. Ord a => Range' a -> a
forall m. Monoid m => Range' m -> m
forall a. Range' a -> Bool
forall a. Range' a -> Int
forall a. Range' a -> [a]
forall a. (a -> a -> a) -> Range' a -> a
forall m a. Monoid m => (a -> m) -> Range' a -> m
forall b a. (b -> a -> b) -> b -> Range' a -> b
forall a b. (a -> b -> b) -> b -> Range' 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 :: Range' a -> a
$cproduct :: forall a. Num a => Range' a -> a
sum :: Range' a -> a
$csum :: forall a. Num a => Range' a -> a
minimum :: Range' a -> a
$cminimum :: forall a. Ord a => Range' a -> a
maximum :: Range' a -> a
$cmaximum :: forall a. Ord a => Range' a -> a
elem :: a -> Range' a -> Bool
$celem :: forall a. Eq a => a -> Range' a -> Bool
length :: Range' a -> Int
$clength :: forall a. Range' a -> Int
null :: Range' a -> Bool
$cnull :: forall a. Range' a -> Bool
toList :: Range' a -> [a]
$ctoList :: forall a. Range' a -> [a]
foldl1 :: (a -> a -> a) -> Range' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Range' a -> a
foldr1 :: (a -> a -> a) -> Range' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Range' a -> a
foldl' :: (b -> a -> b) -> b -> Range' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Range' a -> b
foldl :: (b -> a -> b) -> b -> Range' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Range' a -> b
foldr' :: (a -> b -> b) -> b -> Range' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Range' a -> b
foldr :: (a -> b -> b) -> b -> Range' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Range' a -> b
foldMap' :: (a -> m) -> Range' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Range' a -> m
foldMap :: (a -> m) -> Range' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Range' a -> m
fold :: Range' m -> m
$cfold :: forall m. Monoid m => Range' m -> m
Foldable, Functor Range'
Foldable Range'
Functor Range'
-> Foldable Range'
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range' a -> f (Range' b))
-> (forall (f :: * -> *) a.
Applicative f =>
Range' (f a) -> f (Range' a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range' a -> m (Range' b))
-> (forall (m :: * -> *) a.
Monad m =>
Range' (m a) -> m (Range' a))
-> Traversable Range'
(a -> f b) -> Range' a -> f (Range' 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 => Range' (m a) -> m (Range' a)
forall (f :: * -> *) a.
Applicative f =>
Range' (f a) -> f (Range' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range' a -> m (Range' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range' a -> f (Range' b)
sequence :: Range' (m a) -> m (Range' a)
$csequence :: forall (m :: * -> *) a. Monad m => Range' (m a) -> m (Range' a)
mapM :: (a -> m b) -> Range' a -> m (Range' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Range' a -> m (Range' b)
sequenceA :: Range' (f a) -> f (Range' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Range' (f a) -> f (Range' a)
traverse :: (a -> f b) -> Range' a -> f (Range' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Range' a -> f (Range' b)
$cp2Traversable :: Foldable Range'
$cp1Traversable :: Functor Range'
Traversable, (forall x. Range' a -> Rep (Range' a) x)
-> (forall x. Rep (Range' a) x -> Range' a) -> Generic (Range' a)
forall x. Rep (Range' a) x -> Range' a
forall x. Range' a -> Rep (Range' a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Range' a) x -> Range' a
forall a x. Range' a -> Rep (Range' a) x
$cto :: forall a x. Rep (Range' a) x -> Range' a
$cfrom :: forall a x. Range' a -> Rep (Range' a) x
Generic)
type Range = Range' SrcFile
instance Null (Range' a) where
null :: Range' a -> Bool
null Range' a
NoRange = Bool
True
null Range{} = Bool
False
empty :: Range' a
empty = Range' a
forall a. Range' a
NoRange
rangeIntervals :: Range' a -> [IntervalWithoutFile]
rangeIntervals :: Range' a -> [Interval' ()]
rangeIntervals Range' a
NoRange = []
rangeIntervals (Range a
_ Seq (Interval' ())
is) = Seq (Interval' ()) -> [Interval' ()]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Fold.toList Seq (Interval' ())
is
intervalsToRange :: a -> [IntervalWithoutFile] -> Range' a
intervalsToRange :: a -> [Interval' ()] -> Range' a
intervalsToRange a
_ [] = Range' a
forall a. Range' a
NoRange
intervalsToRange a
f [Interval' ()]
is = a -> Seq (Interval' ()) -> Range' a
forall a. a -> Seq (Interval' ()) -> Range' a
Range a
f ([Interval' ()] -> Seq (Interval' ())
forall a. [a] -> Seq a
Seq.fromList [Interval' ()]
is)
consecutiveAndSeparated :: Ord a => [Interval' a] -> Bool
consecutiveAndSeparated :: [Interval' a] -> Bool
consecutiveAndSeparated [Interval' a]
is =
(Interval' a -> Bool) -> [Interval' a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Interval' a -> Bool
forall a. Ord a => Interval' a -> Bool
intervalInvariant [Interval' a]
is
Bool -> Bool -> Bool
&&
[a] -> Bool
forall a. Eq a => [a] -> Bool
allEqual ((Interval' a -> a) -> [Interval' a] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map (Position' a -> a
forall a. Position' a -> a
srcFile (Position' a -> a)
-> (Interval' a -> Position' a) -> Interval' a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart) [Interval' a]
is)
Bool -> Bool -> Bool
&&
([Interval' a] -> Bool
forall a. Null a => a -> Bool
null [Interval' a]
is
Bool -> Bool -> Bool
||
[Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ((Position' a -> Position' a -> Bool)
-> [Position' a] -> [Position' a] -> [Bool]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
(<) ((Interval' a -> Position' a) -> [Interval' a] -> [Position' a]
forall a b. (a -> b) -> [a] -> [b]
map Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd ([Interval' a] -> [Interval' a]
forall a. [a] -> [a]
init [Interval' a]
is))
((Interval' a -> Position' a) -> [Interval' a] -> [Position' a]
forall a b. (a -> b) -> [a] -> [b]
map Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart ([Interval' a] -> [Interval' a]
forall a. [a] -> [a]
tail [Interval' a]
is))))
rangeInvariant :: Ord a => Range' a -> Bool
rangeInvariant :: Range' a -> Bool
rangeInvariant Range' a
r =
[Interval' ()] -> Bool
forall a. Ord a => [Interval' a] -> Bool
consecutiveAndSeparated (Range' a -> [Interval' ()]
forall a. Range' a -> [Interval' ()]
rangeIntervals Range' a
r)
Bool -> Bool -> Bool
&&
case Range' a
r of
Range a
_ Seq (Interval' ())
is -> Bool -> Bool
not (Seq (Interval' ()) -> Bool
forall a. Null a => a -> Bool
null Seq (Interval' ())
is)
Range' a
NoRange -> Bool
True
rangeFile :: Range -> SrcFile
rangeFile :: Range -> SrcFile
rangeFile Range
NoRange = SrcFile
forall a. Maybe a
Strict.Nothing
rangeFile (Range SrcFile
f Seq (Interval' ())
_) = SrcFile
f
rightMargin :: Range -> Range
rightMargin :: Range -> Range
rightMargin r :: Range
r@Range
NoRange = Range
r
rightMargin r :: Range
r@(Range SrcFile
f Seq (Interval' ())
is) = case Seq (Interval' ()) -> ViewR (Interval' ())
forall a. Seq a -> ViewR a
Seq.viewr Seq (Interval' ())
is of
ViewR (Interval' ())
Seq.EmptyR -> Range
forall a. HasCallStack => a
__IMPOSSIBLE__
Seq (Interval' ())
_ Seq.:> Interval' ()
i -> SrcFile -> Interval' () -> Range
forall a. a -> Interval' () -> Range' a
intervalToRange SrcFile
f (Interval' ()
i { iStart :: PositionWithoutFile
iStart = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iEnd Interval' ()
i })
newtype PrintRange a = PrintRange a
deriving (PrintRange a -> PrintRange a -> Bool
(PrintRange a -> PrintRange a -> Bool)
-> (PrintRange a -> PrintRange a -> Bool) -> Eq (PrintRange a)
forall a. Eq a => PrintRange a -> PrintRange a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrintRange a -> PrintRange a -> Bool
$c/= :: forall a. Eq a => PrintRange a -> PrintRange a -> Bool
== :: PrintRange a -> PrintRange a -> Bool
$c== :: forall a. Eq a => PrintRange a -> PrintRange a -> Bool
Eq, Eq (PrintRange a)
Eq (PrintRange a)
-> (PrintRange a -> PrintRange a -> Ordering)
-> (PrintRange a -> PrintRange a -> Bool)
-> (PrintRange a -> PrintRange a -> Bool)
-> (PrintRange a -> PrintRange a -> Bool)
-> (PrintRange a -> PrintRange a -> Bool)
-> (PrintRange a -> PrintRange a -> PrintRange a)
-> (PrintRange a -> PrintRange a -> PrintRange a)
-> Ord (PrintRange a)
PrintRange a -> PrintRange a -> Bool
PrintRange a -> PrintRange a -> Ordering
PrintRange a -> PrintRange a -> PrintRange 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 (PrintRange a)
forall a. Ord a => PrintRange a -> PrintRange a -> Bool
forall a. Ord a => PrintRange a -> PrintRange a -> Ordering
forall a. Ord a => PrintRange a -> PrintRange a -> PrintRange a
min :: PrintRange a -> PrintRange a -> PrintRange a
$cmin :: forall a. Ord a => PrintRange a -> PrintRange a -> PrintRange a
max :: PrintRange a -> PrintRange a -> PrintRange a
$cmax :: forall a. Ord a => PrintRange a -> PrintRange a -> PrintRange a
>= :: PrintRange a -> PrintRange a -> Bool
$c>= :: forall a. Ord a => PrintRange a -> PrintRange a -> Bool
> :: PrintRange a -> PrintRange a -> Bool
$c> :: forall a. Ord a => PrintRange a -> PrintRange a -> Bool
<= :: PrintRange a -> PrintRange a -> Bool
$c<= :: forall a. Ord a => PrintRange a -> PrintRange a -> Bool
< :: PrintRange a -> PrintRange a -> Bool
$c< :: forall a. Ord a => PrintRange a -> PrintRange a -> Bool
compare :: PrintRange a -> PrintRange a -> Ordering
$ccompare :: forall a. Ord a => PrintRange a -> PrintRange a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (PrintRange a)
Ord, PrintRange a -> Range
(PrintRange a -> Range) -> HasRange (PrintRange a)
forall a. HasRange a => PrintRange a -> Range
forall t. (t -> Range) -> HasRange t
getRange :: PrintRange a -> Range
$cgetRange :: forall a. HasRange a => PrintRange a -> Range
HasRange, HasRange (PrintRange a)
HasRange (PrintRange a)
-> (Range -> PrintRange a -> PrintRange a)
-> SetRange (PrintRange a)
Range -> PrintRange a -> PrintRange a
forall a. SetRange a => HasRange (PrintRange a)
forall a. SetRange a => Range -> PrintRange a -> PrintRange a
forall t. HasRange t -> (Range -> t -> t) -> SetRange t
setRange :: Range -> PrintRange a -> PrintRange a
$csetRange :: forall a. SetRange a => Range -> PrintRange a -> PrintRange a
$cp1SetRange :: forall a. SetRange a => HasRange (PrintRange a)
SetRange, KillRangeT (PrintRange a)
KillRangeT (PrintRange a) -> KillRange (PrintRange a)
forall a. KillRange a => KillRangeT (PrintRange a)
forall a. KillRangeT a -> KillRange a
killRange :: KillRangeT (PrintRange a)
$ckillRange :: forall a. KillRange a => KillRangeT (PrintRange a)
KillRange)
class HasRange t where
getRange :: t -> Range
instance HasRange Interval where
getRange :: Interval -> Range
getRange Interval
i =
SrcFile -> Interval' () -> Range
forall a. a -> Interval' () -> Range' a
intervalToRange (Position' SrcFile -> SrcFile
forall a. Position' a -> a
srcFile (Interval -> Position' SrcFile
forall a. Interval' a -> Position' a
iStart Interval
i))
(() -> Interval -> Interval' ()
forall a b. a -> Interval' b -> Interval' a
setIntervalFile () Interval
i)
instance HasRange Range where
getRange :: Range -> Range
getRange = Range -> Range
forall a. a -> a
id
instance HasRange () where
getRange :: () -> Range
getRange ()
_ = Range
forall a. Range' a
noRange
instance HasRange Bool where
getRange :: Bool -> Range
getRange Bool
_ = Range
forall a. Range' a
noRange
instance HasRange a => HasRange [a] where
getRange :: [a] -> Range
getRange = (a -> Range -> Range) -> Range -> [a] -> Range
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> Range -> Range
forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Range
forall a. Range' a
noRange
instance HasRange a => HasRange (NonEmpty a) where
getRange :: NonEmpty a -> Range
getRange = (a -> Range -> Range) -> Range -> NonEmpty a -> Range
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
Fold.foldr a -> Range -> Range
forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Range
forall a. Range' a
noRange
instance (HasRange a, HasRange b) => HasRange (a,b) where
getRange :: (a, b) -> Range
getRange = (a -> b -> Range) -> (a, b) -> Range
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry a -> b -> Range
forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange
instance (HasRange a, HasRange b, HasRange c) => HasRange (a,b,c) where
getRange :: (a, b, c) -> Range
getRange (a
x,b
y,c
z) = (a, (b, c)) -> Range
forall t. HasRange t => t -> Range
getRange (a
x,(b
y,c
z))
instance (HasRange a, HasRange b, HasRange c, HasRange d) => HasRange (a,b,c,d) where
getRange :: (a, b, c, d) -> Range
getRange (a
x,b
y,c
z,d
w) = (a, (b, (c, d))) -> Range
forall t. HasRange t => t -> Range
getRange (a
x,(b
y,(c
z,d
w)))
instance (HasRange a, HasRange b, HasRange c, HasRange d, HasRange e) => HasRange (a,b,c,d,e) where
getRange :: (a, b, c, d, e) -> Range
getRange (a
x,b
y,c
z,d
w,e
v) = (a, (b, (c, (d, e)))) -> Range
forall t. HasRange t => t -> Range
getRange (a
x,(b
y,(c
z,(d
w,e
v))))
instance (HasRange a, HasRange b, HasRange c, HasRange d, HasRange e, HasRange f) => HasRange (a,b,c,d,e,f) where
getRange :: (a, b, c, d, e, f) -> Range
getRange (a
x,b
y,c
z,d
w,e
v,f
u) = (a, (b, (c, (d, (e, f))))) -> Range
forall t. HasRange t => t -> Range
getRange (a
x,(b
y,(c
z,(d
w,(e
v,f
u)))))
instance (HasRange a, HasRange b, HasRange c, HasRange d, HasRange e, HasRange f, HasRange g) => HasRange (a,b,c,d,e,f,g) where
getRange :: (a, b, c, d, e, f, g) -> Range
getRange (a
x,b
y,c
z,d
w,e
v,f
u,g
t) = (a, (b, (c, (d, (e, (f, g)))))) -> Range
forall t. HasRange t => t -> Range
getRange (a
x,(b
y,(c
z,(d
w,(e
v,(f
u,g
t))))))
instance HasRange a => HasRange (Maybe a) where
getRange :: Maybe a -> Range
getRange = Range -> (a -> Range) -> Maybe a -> Range
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Range
forall a. Range' a
noRange a -> Range
forall t. HasRange t => t -> Range
getRange
instance (HasRange a, HasRange b) => HasRange (Either a b) where
getRange :: Either a b -> Range
getRange = (a -> Range) -> (b -> Range) -> Either a b -> Range
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a -> Range
forall t. HasRange t => t -> Range
getRange b -> Range
forall t. HasRange t => t -> Range
getRange
class HasRange t => SetRange t where
setRange :: Range -> t -> t
instance SetRange Range where
setRange :: Range -> Range -> Range
setRange = Range -> Range -> Range
forall a b. a -> b -> a
const
instance SetRange a => SetRange [a] where
setRange :: Range -> [a] -> [a]
setRange Range
r = (a -> a) -> [a] -> [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> a) -> [a] -> [a]) -> (a -> a) -> [a] -> [a]
forall a b. (a -> b) -> a -> b
$ Range -> a -> a
forall t. SetRange t => Range -> t -> t
setRange Range
r
instance SetRange a => SetRange (Maybe a) where
setRange :: Range -> Maybe a -> Maybe a
setRange Range
r = (a -> a) -> Maybe a -> Maybe a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> a) -> Maybe a -> Maybe a) -> (a -> a) -> Maybe a -> Maybe a
forall a b. (a -> b) -> a -> b
$ Range -> a -> a
forall t. SetRange t => Range -> t -> t
setRange Range
r
class KillRange a where
killRange :: KillRangeT a
type KillRangeT a = a -> a
killRangeMap :: (KillRange k, KillRange v) => KillRangeT (Map k v)
killRangeMap :: KillRangeT (Map k v)
killRangeMap = (k -> k) -> KillRangeT (Map k v)
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic k -> k
forall a. KillRange a => KillRangeT a
killRange KillRangeT (Map k v)
-> KillRangeT (Map k v) -> KillRangeT (Map k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v -> v) -> KillRangeT (Map k v)
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map v -> v
forall a. KillRange a => KillRangeT a
killRange
killRange1 :: KillRange a => (a -> b) -> a -> b
killRange2 :: (KillRange a, KillRange b) => (a -> b -> c) -> a -> b -> c
killRange3 :: (KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange4 :: (KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange5 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e ) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange6 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f ) =>
(a -> b -> c -> d -> e -> f -> g) -> a -> b -> c -> d -> e -> f -> g
killRange7 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g ) =>
(a -> b -> c -> d -> e -> f -> g -> h) -> a -> b -> c -> d -> e -> f -> g -> h
killRange8 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i) ->
a -> b -> c -> d -> e -> f -> g -> h -> i
killRange9 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j
killRange10 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
killRange11 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
killRange12 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
killRange13 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n
killRange14 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o
killRange15 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n, KillRange o ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p
killRange16 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n, KillRange o, KillRange p ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q
killRange17 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n, KillRange o, KillRange p
, KillRange q ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r
killRange18 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n, KillRange o, KillRange p
, KillRange q, KillRange r ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s
killRange19 :: ( KillRange a, KillRange b, KillRange c, KillRange d
, KillRange e, KillRange f, KillRange g, KillRange h
, KillRange i, KillRange j, KillRange k, KillRange l
, KillRange m, KillRange n, KillRange o, KillRange p
, KillRange q, KillRange r, KillRange s ) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t) ->
a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t
killRange1 :: (a -> b) -> a -> b
killRange1 a -> b
f a
a = a -> b
f (KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange2 :: (a -> b -> c) -> a -> b -> c
killRange2 a -> b -> c
f a
a = (b -> c) -> b -> c
forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (a -> b -> c
f (a -> b -> c) -> a -> b -> c
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange3 :: (a -> b -> c -> d) -> a -> b -> c -> d
killRange3 a -> b -> c -> d
f a
a = (b -> c -> d) -> b -> c -> d
forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (a -> b -> c -> d
f (a -> b -> c -> d) -> a -> b -> c -> d
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange4 :: (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 a -> b -> c -> d -> e
f a
a = (b -> c -> d -> e) -> b -> c -> d -> e
forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (a -> b -> c -> d -> e
f (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange5 :: (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange5 a -> b -> c -> d -> e -> f
f a
a = (b -> c -> d -> e -> f) -> b -> c -> d -> e -> f
forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 (a -> b -> c -> d -> e -> f
f (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange6 :: (a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
killRange6 a -> b -> c -> d -> e -> f -> g
f a
a = (b -> c -> d -> e -> f -> g) -> b -> c -> d -> e -> f -> g
forall a b c d e f.
(KillRange a, KillRange b, KillRange c, KillRange d,
KillRange e) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange5 (a -> b -> c -> d -> e -> f -> g
f (a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange7 :: (a -> b -> c -> d -> e -> f -> g -> h)
-> a -> b -> c -> d -> e -> f -> g -> h
killRange7 a -> b -> c -> d -> e -> f -> g -> h
f a
a = (b -> c -> d -> e -> f -> g -> h)
-> b -> c -> d -> e -> f -> g -> h
forall a b c d e f g.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f) =>
(a -> b -> c -> d -> e -> f -> g)
-> a -> b -> c -> d -> e -> f -> g
killRange6 (a -> b -> c -> d -> e -> f -> g -> h
f (a -> b -> c -> d -> e -> f -> g -> h)
-> a -> b -> c -> d -> e -> f -> g -> h
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange8 :: (a -> b -> c -> d -> e -> f -> g -> h -> i)
-> a -> b -> c -> d -> e -> f -> g -> h -> i
killRange8 a -> b -> c -> d -> e -> f -> g -> h -> i
f a
a = (b -> c -> d -> e -> f -> g -> h -> i)
-> b -> c -> d -> e -> f -> g -> h -> i
forall a b c d e f g h.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g) =>
(a -> b -> c -> d -> e -> f -> g -> h)
-> a -> b -> c -> d -> e -> f -> g -> h
killRange7 (a -> b -> c -> d -> e -> f -> g -> h -> i
f (a -> b -> c -> d -> e -> f -> g -> h -> i)
-> a -> b -> c -> d -> e -> f -> g -> h -> i
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange9 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
killRange9 a -> b -> c -> d -> e -> f -> g -> h -> i -> j
f a
a = (b -> c -> d -> e -> f -> g -> h -> i -> j)
-> b -> c -> d -> e -> f -> g -> h -> i -> j
forall a b c d e f g h i.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i)
-> a -> b -> c -> d -> e -> f -> g -> h -> i
killRange8 (a -> b -> c -> d -> e -> f -> g -> h -> i -> j
f (a -> b -> c -> d -> e -> f -> g -> h -> i -> j)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange10 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
killRange10 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
f a
a = (b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
forall a b c d e f g h i j.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
killRange9 (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
f (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange11 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
killRange11 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
f a
a = (b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
forall a b c d e f g h i j k.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
killRange10 (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
f (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange12 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
killRange12 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
f a
a = (b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m)
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
forall a b c d e f g h i j k l.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
killRange11 (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
f (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange13 :: (a
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
killRange13 a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n
f a
a = (b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n)
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n
forall a b c d e f g h i j k l m.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l) =>
(a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m)
-> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
killRange12 (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n
f (a
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange14 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
killRange14 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
f a
a = (b
-> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
forall a b c d e f g h i j k l m n.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m) =>
(a
-> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
killRange13 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange15 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
killRange15 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
f a
a = (b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
forall a b c d e f g h i j k l m n o.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m, KillRange n) =>
(a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
killRange14 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange16 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
killRange16 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
f a
a = (b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
forall a b c d e f g h i j k l m n o p.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m, KillRange n, KillRange o) =>
(a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
killRange15 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange17 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
killRange17 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
f a
a = (b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
forall a b c d e f g h i j k l m n o p q.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m, KillRange n, KillRange o,
KillRange p) =>
(a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
killRange16 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange18 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
killRange18 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
f a
a = (b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
forall a b c d e f g h i j k l m n o p q r.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m, KillRange n, KillRange o,
KillRange p, KillRange q) =>
(a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
killRange17 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
killRange19 :: (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t
killRange19 a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t
f a
a = (b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t)
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t
forall a b c d e f g h i j k l m n o p q r s.
(KillRange a, KillRange b, KillRange c, KillRange d, KillRange e,
KillRange f, KillRange g, KillRange h, KillRange i, KillRange j,
KillRange k, KillRange l, KillRange m, KillRange n, KillRange o,
KillRange p, KillRange q, KillRange r) =>
(a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
killRange18 (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t
f (a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t)
-> a
-> b
-> c
-> d
-> e
-> f
-> g
-> h
-> i
-> j
-> k
-> l
-> m
-> n
-> o
-> p
-> q
-> r
-> s
-> t
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
a)
instance KillRange Range where
killRange :: Range -> Range
killRange Range
_ = Range
forall a. Range' a
noRange
instance KillRange Void where
killRange :: KillRangeT Void
killRange = KillRangeT Void
forall a. a -> a
id
instance KillRange () where
killRange :: KillRangeT ()
killRange = KillRangeT ()
forall a. a -> a
id
instance KillRange Bool where
killRange :: Bool -> Bool
killRange = Bool -> Bool
forall a. a -> a
id
instance KillRange Int where
killRange :: KillRangeT Int
killRange = KillRangeT Int
forall a. a -> a
id
instance KillRange Integer where
killRange :: KillRangeT Integer
killRange = KillRangeT Integer
forall a. a -> a
id
instance {-# OVERLAPPABLE #-} KillRange a => KillRange [a] where
killRange :: KillRangeT [a]
killRange = (a -> a) -> KillRangeT [a]
forall a b. (a -> b) -> [a] -> [b]
map a -> a
forall a. KillRange a => KillRangeT a
killRange
instance KillRange a => KillRange (NonEmpty a) where
killRange :: KillRangeT (NonEmpty a)
killRange = (a -> a) -> KillRangeT (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. KillRange a => KillRangeT a
killRange
instance {-# OVERLAPPING #-} KillRange String where
killRange :: KillRangeT String
killRange = KillRangeT String
forall a. a -> a
id
instance {-# OVERLAPPABLE #-} KillRange a => KillRange (Map k a) where
killRange :: KillRangeT (Map k a)
killRange = (a -> a) -> KillRangeT (Map k a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. KillRange a => KillRangeT a
killRange
instance {-# OVERLAPPABLE #-} (Ord a, KillRange a) => KillRange (Set a) where
killRange :: KillRangeT (Set a)
killRange = (a -> a) -> KillRangeT (Set a)
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map a -> a
forall a. KillRange a => KillRangeT a
killRange
instance (KillRange a, KillRange b) => KillRange (a, b) where
killRange :: KillRangeT (a, b)
killRange (a
x, b
y) = (KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
x, KillRangeT b
forall a. KillRange a => KillRangeT a
killRange b
y)
instance (KillRange a, KillRange b, KillRange c) =>
KillRange (a, b, c) where
killRange :: KillRangeT (a, b, c)
killRange (a
x, b
y, c
z) = (a -> b -> c -> (a, b, c)) -> a -> b -> c -> (a, b, c)
forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (,,) a
x b
y c
z
instance (KillRange a, KillRange b, KillRange c, KillRange d) =>
KillRange (a, b, c, d) where
killRange :: KillRangeT (a, b, c, d)
killRange (a
x, b
y, c
z, d
u) = (a -> b -> c -> d -> (a, b, c, d))
-> a -> b -> c -> d -> (a, b, c, d)
forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 (,,,) a
x b
y c
z d
u
instance KillRange a => KillRange (Maybe a) where
killRange :: KillRangeT (Maybe a)
killRange = (a -> a) -> KillRangeT (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. KillRange a => KillRangeT a
killRange
instance KillRange a => KillRange (Strict.Maybe a) where
killRange :: KillRangeT (Maybe a)
killRange = (a -> a) -> KillRangeT (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. KillRange a => KillRangeT a
killRange
instance (KillRange a, KillRange b) => KillRange (Either a b) where
killRange :: KillRangeT (Either a b)
killRange (Left a
x) = a -> Either a b
forall a b. a -> Either a b
Left (a -> Either a b) -> a -> Either a b
forall a b. (a -> b) -> a -> b
$ KillRangeT a
forall a. KillRange a => KillRangeT a
killRange a
x
killRange (Right b
x) = b -> Either a b
forall a b. b -> Either a b
Right (b -> Either a b) -> b -> Either a b
forall a b. (a -> b) -> a -> b
$ KillRangeT b
forall a. KillRange a => KillRangeT a
killRange b
x
instance Show a => Show (Position' (Strict.Maybe a)) where
show :: Position' (Maybe a) -> String
show (Pn (Strict.Just a
f) Int32
_ Int32
l Int32
c) = a -> String
forall a. Show a => a -> String
show a
f String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
":" String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++
Int32 -> String
forall a. Show a => a -> String
show Int32
l String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
"," String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ Int32 -> String
forall a. Show a => a -> String
show Int32
c
show (Pn Maybe a
Strict.Nothing Int32
_ Int32
l Int32
c) = Int32 -> String
forall a. Show a => a -> String
show Int32
l String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
"," String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ Int32 -> String
forall a. Show a => a -> String
show Int32
c
instance Show PositionWithoutFile where
show :: PositionWithoutFile -> String
show PositionWithoutFile
p = Position' SrcFile -> String
forall a. Show a => a -> String
show (PositionWithoutFile
p { srcFile :: SrcFile
srcFile = SrcFile
forall a. Maybe a
Strict.Nothing } :: Position)
instance Show IntervalWithoutFile where
show :: Interval' () -> String
show (Interval PositionWithoutFile
s PositionWithoutFile
e) = String
start String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
"-" String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
end
where
sl :: Int32
sl = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posLine PositionWithoutFile
s
el :: Int32
el = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posLine PositionWithoutFile
e
sc :: Int32
sc = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posCol PositionWithoutFile
s
ec :: Int32
ec = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posCol PositionWithoutFile
e
start :: String
start :: String
start = Int32 -> String
forall a. Show a => a -> String
show Int32
sl String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
"," String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ Int32 -> String
forall a. Show a => a -> String
show Int32
sc
end :: String
end :: String
end | Int32
sl Int32 -> Int32 -> Bool
forall a. Eq a => a -> a -> Bool
== Int32
el = Int32 -> String
forall a. Show a => a -> String
show Int32
ec
| Bool
otherwise = Int32 -> String
forall a. Show a => a -> String
show Int32
el String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
"," String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ Int32 -> String
forall a. Show a => a -> String
show Int32
ec
instance Show a => Show (Interval' (Strict.Maybe a)) where
show :: Interval' (Maybe a) -> String
show i :: Interval' (Maybe a)
i@(Interval Position' (Maybe a)
s Position' (Maybe a)
_) = String
file String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ Interval' () -> String
forall a. Show a => a -> String
show (() -> Interval' (Maybe a) -> Interval' ()
forall a b. a -> Interval' b -> Interval' a
setIntervalFile () Interval' (Maybe a)
i)
where
file :: String
file :: String
file = case Position' (Maybe a) -> Maybe a
forall a. Position' a -> a
srcFile Position' (Maybe a)
s of
Maybe a
Strict.Nothing -> String
""
Strict.Just a
f -> a -> String
forall a. Show a => a -> String
show a
f String -> KillRangeT String
forall a. [a] -> [a] -> [a]
++ String
":"
instance Show a => Show (Range' (Strict.Maybe a)) where
show :: Range' (Maybe a) -> String
show Range' (Maybe a)
r = case Range' (Maybe a) -> Maybe (Interval' (Maybe a))
forall a. Range' a -> Maybe (Interval' a)
rangeToIntervalWithFile Range' (Maybe a)
r of
Maybe (Interval' (Maybe a))
Nothing -> String
""
Just Interval' (Maybe a)
i -> Interval' (Maybe a) -> String
forall a. Show a => a -> String
show Interval' (Maybe a)
i
instance Show a => Show (Range' (Maybe a)) where
show :: Range' (Maybe a) -> String
show = Range' (Maybe a) -> String
forall a. Show a => a -> String
show (Range' (Maybe a) -> String)
-> (Range' (Maybe a) -> Range' (Maybe a))
-> Range' (Maybe a)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe a -> Maybe a) -> Range' (Maybe a) -> Range' (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe a -> Maybe a
forall a. Maybe a -> Maybe a
Strict.toStrict
instance Pretty a => Pretty (Position' (Strict.Maybe a)) where
pretty :: Position' (Maybe a) -> Doc
pretty (Pn Maybe a
Strict.Nothing Int32
_ Int32
l Int32
c) = Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
l Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"," Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
c
pretty (Pn (Strict.Just a
f) Int32
_ Int32
l Int32
c) =
a -> Doc
forall a. Pretty a => a -> Doc
pretty a
f Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
":" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
l Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"," Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
c
instance Pretty PositionWithoutFile where
pretty :: PositionWithoutFile -> Doc
pretty PositionWithoutFile
p = Position' SrcFile -> Doc
forall a. Pretty a => a -> Doc
pretty (PositionWithoutFile
p { srcFile :: SrcFile
srcFile = SrcFile
forall a. Maybe a
Strict.Nothing } :: Position)
instance Pretty IntervalWithoutFile where
pretty :: Interval' () -> Doc
pretty (Interval PositionWithoutFile
s PositionWithoutFile
e) = Doc
start Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"-" Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
end
where
sl :: Int32
sl = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posLine PositionWithoutFile
s
el :: Int32
el = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posLine PositionWithoutFile
e
sc :: Int32
sc = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posCol PositionWithoutFile
s
ec :: Int32
ec = PositionWithoutFile -> Int32
forall a. Position' a -> Int32
posCol PositionWithoutFile
e
start :: Doc
start :: Doc
start = Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
sl Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
comma Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
sc
Doc
end :: Doc
| Int32
sl Int32 -> Int32 -> Bool
forall a. Eq a => a -> a -> Bool
== Int32
el = Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
ec
| Bool
otherwise = Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
el Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
comma Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Int32 -> Doc
forall a. Pretty a => a -> Doc
pretty Int32
ec
instance Pretty a => Pretty (Interval' (Strict.Maybe a)) where
pretty :: Interval' (Maybe a) -> Doc
pretty i :: Interval' (Maybe a)
i@(Interval Position' (Maybe a)
s Position' (Maybe a)
_) = Doc
file Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Interval' () -> Doc
forall a. Pretty a => a -> Doc
pretty (() -> Interval' (Maybe a) -> Interval' ()
forall a b. a -> Interval' b -> Interval' a
setIntervalFile () Interval' (Maybe a)
i)
where
file :: Doc
file :: Doc
file = case Position' (Maybe a) -> Maybe a
forall a. Position' a -> a
srcFile Position' (Maybe a)
s of
Maybe a
Strict.Nothing -> Doc
forall a. Null a => a
empty
Strict.Just a
f -> a -> Doc
forall a. Pretty a => a -> Doc
pretty a
f Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
colon
instance Pretty a => Pretty (Range' (Strict.Maybe a)) where
pretty :: Range' (Maybe a) -> Doc
pretty Range' (Maybe a)
r = case Range' (Maybe a) -> Maybe (Interval' (Maybe a))
forall a. Range' a -> Maybe (Interval' a)
rangeToIntervalWithFile Range' (Maybe a)
r of
Maybe (Interval' (Maybe a))
Nothing -> Doc
forall a. Null a => a
empty
Just Interval' (Maybe a)
i -> Interval' (Maybe a) -> Doc
forall a. Pretty a => a -> Doc
pretty Interval' (Maybe a)
i
instance (Pretty a, HasRange a) => Pretty (PrintRange a) where
pretty :: PrintRange a -> Doc
pretty (PrintRange a
a) = a -> Doc
forall a. Pretty a => a -> Doc
pretty a
a Doc -> Doc -> Doc
<+> Doc -> Doc
parens (Doc
"at" Doc -> Doc -> Doc
<+> Range -> Doc
forall a. Pretty a => a -> Doc
pretty (a -> Range
forall t. HasRange t => t -> Range
getRange a
a))
startPos' :: a -> Position' a
startPos' :: a -> Position' a
startPos' a
f = Pn :: forall a. a -> Int32 -> Int32 -> Int32 -> Position' a
Pn
{ srcFile :: a
srcFile = a
f
, posPos :: Int32
posPos = Int32
1
, posLine :: Int32
posLine = Int32
1
, posCol :: Int32
posCol = Int32
1
}
startPos :: Maybe AbsolutePath -> Position
startPos :: Maybe AbsolutePath -> Position' SrcFile
startPos = SrcFile -> Position' SrcFile
forall a. a -> Position' a
startPos' (SrcFile -> Position' SrcFile)
-> (Maybe AbsolutePath -> SrcFile)
-> Maybe AbsolutePath
-> Position' SrcFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe AbsolutePath -> SrcFile
forall a. Maybe a -> Maybe a
Strict.toStrict
noRange :: Range' a
noRange :: Range' a
noRange = Range' a
forall a. Range' a
NoRange
movePos :: Position' a -> Char -> Position' a
movePos :: Position' a -> Char -> Position' a
movePos (Pn a
f Int32
p Int32
l Int32
c) Char
'\n' = a -> Int32 -> Int32 -> Int32 -> Position' a
forall a. a -> Int32 -> Int32 -> Int32 -> Position' a
Pn a
f (Int32
p Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
1) (Int32
l Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
1) Int32
1
movePos (Pn a
f Int32
p Int32
l Int32
c) Char
_ = a -> Int32 -> Int32 -> Int32 -> Position' a
forall a. a -> Int32 -> Int32 -> Int32 -> Position' a
Pn a
f (Int32
p Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
1) Int32
l (Int32
c Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
1)
movePosByString :: Position' a -> String -> Position' a
movePosByString :: Position' a -> String -> Position' a
movePosByString = (Position' a -> Char -> Position' a)
-> Position' a -> String -> Position' a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Position' a -> Char -> Position' a
forall a. Position' a -> Char -> Position' a
movePos
backupPos :: Position' a -> Position' a
backupPos :: Position' a -> Position' a
backupPos (Pn a
f Int32
p Int32
l Int32
c) = a -> Int32 -> Int32 -> Int32 -> Position' a
forall a. a -> Int32 -> Int32 -> Int32 -> Position' a
Pn a
f (Int32
p Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
1) Int32
l (Int32
c Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
1)
posToRange' ::
a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
posToRange' :: a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
posToRange' a
f PositionWithoutFile
p1 PositionWithoutFile
p2 = a -> Interval' () -> Range' a
forall a. a -> Interval' () -> Range' a
intervalToRange a
f (() -> PositionWithoutFile -> PositionWithoutFile -> Interval' ()
forall a.
a -> PositionWithoutFile -> PositionWithoutFile -> Interval' a
posToInterval () PositionWithoutFile
p1 PositionWithoutFile
p2)
posToRange :: Position' a -> Position' a -> Range' a
posToRange :: Position' a -> Position' a -> Range' a
posToRange Position' a
p1 Position' a
p2 =
a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
forall a.
a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
posToRange' (Position' a -> a
forall a. Position' a -> a
srcFile Position' a
p1) (Position' a
p1 { srcFile :: ()
srcFile = () }) (Position' a
p2 { srcFile :: ()
srcFile = () })
intervalToRange :: a -> IntervalWithoutFile -> Range' a
intervalToRange :: a -> Interval' () -> Range' a
intervalToRange a
f Interval' ()
i = a -> Seq (Interval' ()) -> Range' a
forall a. a -> Seq (Interval' ()) -> Range' a
Range a
f (Interval' () -> Seq (Interval' ())
forall a. a -> Seq a
Seq.singleton Interval' ()
i)
rangeToIntervalWithFile :: Range' a -> Maybe (Interval' a)
rangeToIntervalWithFile :: Range' a -> Maybe (Interval' a)
rangeToIntervalWithFile Range' a
NoRange = Maybe (Interval' a)
forall a. Maybe a
Nothing
rangeToIntervalWithFile (Range a
f Seq (Interval' ())
is) = case (Seq (Interval' ()) -> ViewL (Interval' ())
forall a. Seq a -> ViewL a
Seq.viewl Seq (Interval' ())
is, Seq (Interval' ()) -> ViewR (Interval' ())
forall a. Seq a -> ViewR a
Seq.viewr Seq (Interval' ())
is) of
(Interval' ()
head Seq.:< Seq (Interval' ())
_, Seq (Interval' ())
_ Seq.:> Interval' ()
last) -> Interval' a -> Maybe (Interval' a)
forall a. a -> Maybe a
Just (Interval' a -> Maybe (Interval' a))
-> Interval' a -> Maybe (Interval' a)
forall a b. (a -> b) -> a -> b
$ a -> Interval' () -> Interval' a
forall a b. a -> Interval' b -> Interval' a
setIntervalFile a
f (Interval' () -> Interval' a) -> Interval' () -> Interval' a
forall a b. (a -> b) -> a -> b
$
Interval :: forall a. Position' a -> Position' a -> Interval' a
Interval { iStart :: PositionWithoutFile
iStart = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iStart Interval' ()
head
, iEnd :: PositionWithoutFile
iEnd = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iEnd Interval' ()
last
}
(ViewL (Interval' ()), ViewR (Interval' ()))
_ -> Maybe (Interval' a)
forall a. HasCallStack => a
__IMPOSSIBLE__
rangeToInterval :: Range' a -> Maybe IntervalWithoutFile
rangeToInterval :: Range' a -> Maybe (Interval' ())
rangeToInterval Range' a
NoRange = Maybe (Interval' ())
forall a. Maybe a
Nothing
rangeToInterval (Range a
_ Seq (Interval' ())
is) = case (Seq (Interval' ()) -> ViewL (Interval' ())
forall a. Seq a -> ViewL a
Seq.viewl Seq (Interval' ())
is, Seq (Interval' ()) -> ViewR (Interval' ())
forall a. Seq a -> ViewR a
Seq.viewr Seq (Interval' ())
is) of
(Interval' ()
head Seq.:< Seq (Interval' ())
_, Seq (Interval' ())
_ Seq.:> Interval' ()
last) -> Interval' () -> Maybe (Interval' ())
forall a. a -> Maybe a
Just (Interval' () -> Maybe (Interval' ()))
-> Interval' () -> Maybe (Interval' ())
forall a b. (a -> b) -> a -> b
$
Interval :: forall a. Position' a -> Position' a -> Interval' a
Interval { iStart :: PositionWithoutFile
iStart = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iStart Interval' ()
head
, iEnd :: PositionWithoutFile
iEnd = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iEnd Interval' ()
last
}
(ViewL (Interval' ()), ViewR (Interval' ()))
_ -> Maybe (Interval' ())
forall a. HasCallStack => a
__IMPOSSIBLE__
continuous :: Range' a -> Range' a
continuous :: Range' a -> Range' a
continuous Range' a
NoRange = Range' a
forall a. Range' a
NoRange
continuous r :: Range' a
r@(Range a
f Seq (Interval' ())
_) = case Range' a -> Maybe (Interval' ())
forall a. Range' a -> Maybe (Interval' ())
rangeToInterval Range' a
r of
Maybe (Interval' ())
Nothing -> Range' a
forall a. HasCallStack => a
__IMPOSSIBLE__
Just Interval' ()
i -> a -> Interval' () -> Range' a
forall a. a -> Interval' () -> Range' a
intervalToRange a
f Interval' ()
i
continuousPerLine :: Ord a => Range' a -> Range' a
continuousPerLine :: Range' a -> Range' a
continuousPerLine r :: Range' a
r@Range' a
NoRange = Range' a
r
continuousPerLine r :: Range' a
r@(Range a
f Seq (Interval' ())
_) =
a -> Seq (Interval' ()) -> Range' a
forall a. a -> Seq (Interval' ()) -> Range' a
Range a
f (([Interval' ()] -> Maybe (Interval' (), [Interval' ()]))
-> [Interval' ()] -> Seq (Interval' ())
forall b a. (b -> Maybe (a, b)) -> b -> Seq a
Seq.unfoldr [Interval' ()] -> Maybe (Interval' (), [Interval' ()])
forall a.
Ord a =>
[Interval' a] -> Maybe (Interval' a, [Interval' a])
step (Range' a -> [Interval' ()]
forall a. Range' a -> [Interval' ()]
rangeIntervals Range' a
r))
where
step :: [Interval' a] -> Maybe (Interval' a, [Interval' a])
step [] = Maybe (Interval' a, [Interval' a])
forall a. Maybe a
Nothing
step [Interval' a
i] = (Interval' a, [Interval' a]) -> Maybe (Interval' a, [Interval' a])
forall a. a -> Maybe a
Just (Interval' a
i, [])
step (Interval' a
i : is :: [Interval' a]
is@(Interval' a
j : [Interval' a]
js))
| Bool
sameLine = [Interval' a] -> Maybe (Interval' a, [Interval' a])
step (Interval' a -> Interval' a -> Interval' a
forall a. Ord a => Interval' a -> Interval' a -> Interval' a
fuseIntervals Interval' a
i Interval' a
j Interval' a -> [Interval' a] -> [Interval' a]
forall a. a -> [a] -> [a]
: [Interval' a]
js)
| Bool
otherwise = (Interval' a, [Interval' a]) -> Maybe (Interval' a, [Interval' a])
forall a. a -> Maybe a
Just (Interval' a
i, [Interval' a]
is)
where
sameLine :: Bool
sameLine = Position' a -> Int32
forall a. Position' a -> Int32
posLine (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
i) Int32 -> Int32 -> Bool
forall a. Eq a => a -> a -> Bool
== Position' a -> Int32
forall a. Position' a -> Int32
posLine (Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
j)
rStart' :: Range' a -> Maybe PositionWithoutFile
rStart' :: Range' a -> Maybe PositionWithoutFile
rStart' Range' a
r = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iStart (Interval' () -> PositionWithoutFile)
-> Maybe (Interval' ()) -> Maybe PositionWithoutFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range' a -> Maybe (Interval' ())
forall a. Range' a -> Maybe (Interval' ())
rangeToInterval Range' a
r
rStart :: Range' a -> Maybe (Position' a)
rStart :: Range' a -> Maybe (Position' a)
rStart Range' a
NoRange = Maybe (Position' a)
forall a. Maybe a
Nothing
rStart r :: Range' a
r@(Range a
f Seq (Interval' ())
_) = (\PositionWithoutFile
p -> PositionWithoutFile
p { srcFile :: a
srcFile = a
f }) (PositionWithoutFile -> Position' a)
-> Maybe PositionWithoutFile -> Maybe (Position' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range' a -> Maybe PositionWithoutFile
forall a. Range' a -> Maybe PositionWithoutFile
rStart' Range' a
r
rEnd' :: Range' a -> Maybe PositionWithoutFile
rEnd' :: Range' a -> Maybe PositionWithoutFile
rEnd' Range' a
r = Interval' () -> PositionWithoutFile
forall a. Interval' a -> Position' a
iEnd (Interval' () -> PositionWithoutFile)
-> Maybe (Interval' ()) -> Maybe PositionWithoutFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range' a -> Maybe (Interval' ())
forall a. Range' a -> Maybe (Interval' ())
rangeToInterval Range' a
r
rEnd :: Range' a -> Maybe (Position' a)
rEnd :: Range' a -> Maybe (Position' a)
rEnd Range' a
NoRange = Maybe (Position' a)
forall a. Maybe a
Nothing
rEnd r :: Range' a
r@(Range a
f Seq (Interval' ())
_) = (\PositionWithoutFile
p -> PositionWithoutFile
p { srcFile :: a
srcFile = a
f }) (PositionWithoutFile -> Position' a)
-> Maybe PositionWithoutFile -> Maybe (Position' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range' a -> Maybe PositionWithoutFile
forall a. Range' a -> Maybe PositionWithoutFile
rEnd' Range' a
r
fuseIntervals :: Ord a => Interval' a -> Interval' a -> Interval' a
fuseIntervals :: Interval' a -> Interval' a -> Interval' a
fuseIntervals Interval' a
x Interval' a
y = Interval :: forall a. Position' a -> Position' a -> Interval' a
Interval { iStart :: Position' a
iStart = [Position' a] -> Position' a
forall a. [a] -> a
head [Position' a]
ss, iEnd :: Position' a
iEnd = [Position' a] -> Position' a
forall a. [a] -> a
last [Position' a]
es }
where
ss :: [Position' a]
ss = [Position' a] -> [Position' a]
forall a. Ord a => [a] -> [a]
sort [Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
x, Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
y]
es :: [Position' a]
es = [Position' a] -> [Position' a]
forall a. Ord a => [a] -> [a]
sort [Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
x, Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
y]
fuseRanges :: (Ord a) => Range' a -> Range' a -> Range' a
fuseRanges :: Range' a -> Range' a -> Range' a
fuseRanges Range' a
NoRange Range' a
is2 = Range' a
is2
fuseRanges Range' a
is1 Range' a
NoRange = Range' a
is1
fuseRanges (Range a
f Seq (Interval' ())
is1) (Range a
_ Seq (Interval' ())
is2) = a -> Seq (Interval' ()) -> Range' a
forall a. a -> Seq (Interval' ()) -> Range' a
Range a
f (Seq (Interval' ()) -> Seq (Interval' ()) -> Seq (Interval' ())
forall a.
Ord a =>
Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
fuse Seq (Interval' ())
is1 Seq (Interval' ())
is2)
where
fuse :: Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
fuse Seq (Interval' a)
is1 Seq (Interval' a)
is2 = case (Seq (Interval' a) -> ViewL (Interval' a)
forall a. Seq a -> ViewL a
Seq.viewl Seq (Interval' a)
is1, Seq (Interval' a) -> ViewR (Interval' a)
forall a. Seq a -> ViewR a
Seq.viewr Seq (Interval' a)
is1,
Seq (Interval' a) -> ViewL (Interval' a)
forall a. Seq a -> ViewL a
Seq.viewl Seq (Interval' a)
is2, Seq (Interval' a) -> ViewR (Interval' a)
forall a. Seq a -> ViewR a
Seq.viewr Seq (Interval' a)
is2) of
(ViewL (Interval' a)
Seq.EmptyL, ViewR (Interval' a)
_, ViewL (Interval' a)
_, ViewR (Interval' a)
_) -> Seq (Interval' a)
is2
(ViewL (Interval' a)
_, ViewR (Interval' a)
_, ViewL (Interval' a)
Seq.EmptyL, ViewR (Interval' a)
_) -> Seq (Interval' a)
is1
(Interval' a
s1 Seq.:< Seq (Interval' a)
r1, Seq (Interval' a)
l1 Seq.:> Interval' a
e1, Interval' a
s2 Seq.:< Seq (Interval' a)
r2, Seq (Interval' a)
l2 Seq.:> Interval' a
e2)
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
e1 Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s2 -> Seq (Interval' a)
is1 Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
forall a. Seq a -> Seq a -> Seq a
Seq.>< Seq (Interval' a)
is2
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
e2 Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s1 -> Seq (Interval' a)
is2 Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
forall a. Seq a -> Seq a -> Seq a
Seq.>< Seq (Interval' a)
is1
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
e1 Position' a -> Position' a -> Bool
forall a. Eq a => a -> a -> Bool
== Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s2 -> Seq (Interval' a)
-> Interval' a
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
forall a.
Seq (Interval' a)
-> Interval' a
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
mergeTouching Seq (Interval' a)
l1 Interval' a
e1 Interval' a
s2 Seq (Interval' a)
r2
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
e2 Position' a -> Position' a -> Bool
forall a. Eq a => a -> a -> Bool
== Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s1 -> Seq (Interval' a)
-> Interval' a
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
forall a.
Seq (Interval' a)
-> Interval' a
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
mergeTouching Seq (Interval' a)
l2 Interval' a
e2 Interval' a
s1 Seq (Interval' a)
r1
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s1 Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s2 -> Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
outputLeftPrefix Interval' a
s1 Seq (Interval' a)
r1 Interval' a
s2 Seq (Interval' a)
is2
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s2 Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s1 -> Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
outputLeftPrefix Interval' a
s2 Seq (Interval' a)
r2 Interval' a
s1 Seq (Interval' a)
is1
| Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s1 Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s2 -> Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
fuseSome Interval' a
s1 Seq (Interval' a)
r1 Interval' a
s2 Seq (Interval' a)
r2
| Bool
otherwise -> Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
fuseSome Interval' a
s2 Seq (Interval' a)
r2 Interval' a
s1 Seq (Interval' a)
r1
(ViewL (Interval' a), ViewR (Interval' a), ViewL (Interval' a),
ViewR (Interval' a))
_ -> Seq (Interval' a)
forall a. HasCallStack => a
__IMPOSSIBLE__
mergeTouching :: Seq (Interval' a)
-> Interval' a
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
mergeTouching Seq (Interval' a)
l Interval' a
e Interval' a
s Seq (Interval' a)
r = Seq (Interval' a)
l Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
forall a. Seq a -> Seq a -> Seq a
Seq.>< Interval' a
i Interval' a -> Seq (Interval' a) -> Seq (Interval' a)
forall a. a -> Seq a -> Seq a
Seq.<| Seq (Interval' a)
r
where
i :: Interval' a
i = Interval :: forall a. Position' a -> Position' a -> Interval' a
Interval { iStart :: Position' a
iStart = Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
e, iEnd :: Position' a
iEnd = Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s }
outputLeftPrefix :: Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
outputLeftPrefix Interval' a
s1 Seq (Interval' a)
r1 Interval' a
s2 Seq (Interval' a)
is2 = Interval' a
s1 Interval' a -> Seq (Interval' a) -> Seq (Interval' a)
forall a. a -> Seq a -> Seq a
Seq.<| Seq (Interval' a)
r1' Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
forall a. Seq a -> Seq a -> Seq a
Seq.>< Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
fuse Seq (Interval' a)
r1'' Seq (Interval' a)
is2
where
(Seq (Interval' a)
r1', Seq (Interval' a)
r1'') = (Interval' a -> Bool)
-> Seq (Interval' a) -> (Seq (Interval' a), Seq (Interval' a))
forall a. (a -> Bool) -> Seq a -> (Seq a, Seq a)
Seq.spanl (\Interval' a
s -> Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
< Interval' a -> Position' a
forall a. Interval' a -> Position' a
iStart Interval' a
s2) Seq (Interval' a)
r1
fuseSome :: Interval' a
-> Seq (Interval' a)
-> Interval' a
-> Seq (Interval' a)
-> Seq (Interval' a)
fuseSome Interval' a
s1 Seq (Interval' a)
r1 Interval' a
s2 Seq (Interval' a)
r2 = Seq (Interval' a) -> Seq (Interval' a) -> Seq (Interval' a)
fuse Seq (Interval' a)
r1' (Interval' a -> Interval' a -> Interval' a
forall a. Ord a => Interval' a -> Interval' a -> Interval' a
fuseIntervals Interval' a
s1 Interval' a
s2 Interval' a -> Seq (Interval' a) -> Seq (Interval' a)
forall a. a -> Seq a -> Seq a
Seq.<| Seq (Interval' a)
r2)
where
r1' :: Seq (Interval' a)
r1' = (Interval' a -> Bool) -> Seq (Interval' a) -> Seq (Interval' a)
forall a. (a -> Bool) -> Seq a -> Seq a
Seq.dropWhileL (\Interval' a
s -> Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s Position' a -> Position' a -> Bool
forall a. Ord a => a -> a -> Bool
<= Interval' a -> Position' a
forall a. Interval' a -> Position' a
iEnd Interval' a
s2) Seq (Interval' a)
r1
fuseRange :: (HasRange u, HasRange t) => u -> t -> Range
fuseRange :: u -> t -> Range
fuseRange u
x t
y = Range -> Range -> Range
forall a. Ord a => Range' a -> Range' a -> Range' a
fuseRanges (u -> Range
forall t. HasRange t => t -> Range
getRange u
x) (t -> Range
forall t. HasRange t => t -> Range
getRange t
y)
beginningOf :: Range -> Range
beginningOf :: Range -> Range
beginningOf Range
NoRange = Range
forall a. Range' a
NoRange
beginningOf r :: Range
r@(Range SrcFile
f Seq (Interval' ())
_) = case Range -> Maybe PositionWithoutFile
forall a. Range' a -> Maybe PositionWithoutFile
rStart' Range
r of
Maybe PositionWithoutFile
Nothing -> Range
forall a. HasCallStack => a
__IMPOSSIBLE__
Just PositionWithoutFile
pos -> SrcFile -> PositionWithoutFile -> PositionWithoutFile -> Range
forall a.
a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
posToRange' SrcFile
f PositionWithoutFile
pos PositionWithoutFile
pos
beginningOfFile :: Range -> Range
beginningOfFile :: Range -> Range
beginningOfFile Range
NoRange = Range
forall a. Range' a
NoRange
beginningOfFile (Range SrcFile
f Seq (Interval' ())
_) = SrcFile -> PositionWithoutFile -> PositionWithoutFile -> Range
forall a.
a -> PositionWithoutFile -> PositionWithoutFile -> Range' a
posToRange' SrcFile
f PositionWithoutFile
p PositionWithoutFile
p
where p :: PositionWithoutFile
p = () -> PositionWithoutFile
forall a. a -> Position' a
startPos' ()
withRangeOf :: (SetRange t, HasRange u) => t -> u -> t
t
x withRangeOf :: t -> u -> t
`withRangeOf` u
y = Range -> t -> t
forall t. SetRange t => Range -> t -> t
setRange (u -> Range
forall t. HasRange t => t -> Range
getRange u
y) t
x
interleaveRanges :: (HasRange a) => [a] -> [a] -> ([a], [(a,a)])
interleaveRanges :: [a] -> [a] -> ([a], [(a, a)])
interleaveRanges [a]
as [a]
bs = Writer [(a, a)] [a] -> ([a], [(a, a)])
forall w a. Writer w a -> (a, w)
runWriter(Writer [(a, a)] [a] -> ([a], [(a, a)]))
-> Writer [(a, a)] [a] -> ([a], [(a, a)])
forall a b. (a -> b) -> a -> b
$ [a] -> [a] -> Writer [(a, a)] [a]
forall (f :: * -> *) a.
(MonadWriter [(a, a)] f, HasRange a) =>
[a] -> [a] -> f [a]
go [a]
as [a]
bs
where
go :: [a] -> [a] -> f [a]
go [] [a]
as = [a] -> f [a]
forall (m :: * -> *) a. Monad m => a -> m a
return [a]
as
go [a]
as [] = [a] -> f [a]
forall (m :: * -> *) a. Monad m => a -> m a
return [a]
as
go as :: [a]
as@(a
a:[a]
as') bs :: [a]
bs@(a
b:[a]
bs') =
let ra :: Range
ra = a -> Range
forall t. HasRange t => t -> Range
getRange a
a
rb :: Range
rb = a -> Range
forall t. HasRange t => t -> Range
getRange a
b
ra0 :: Maybe (Position' SrcFile)
ra0 = Range -> Maybe (Position' SrcFile)
forall a. Range' a -> Maybe (Position' a)
rStart Range
ra
rb0 :: Maybe (Position' SrcFile)
rb0 = Range -> Maybe (Position' SrcFile)
forall a. Range' a -> Maybe (Position' a)
rStart Range
rb
ra1 :: Maybe (Position' SrcFile)
ra1 = Range -> Maybe (Position' SrcFile)
forall a. Range' a -> Maybe (Position' a)
rEnd Range
ra
rb1 :: Maybe (Position' SrcFile)
rb1 = Range -> Maybe (Position' SrcFile)
forall a. Range' a -> Maybe (Position' a)
rEnd Range
rb
in
if Maybe (Position' SrcFile)
ra1 Maybe (Position' SrcFile) -> Maybe (Position' SrcFile) -> Bool
forall a. Ord a => a -> a -> Bool
<= Maybe (Position' SrcFile)
rb0 then
(a
aa -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [a] -> f [a]
go [a]
as' [a]
bs
else if Maybe (Position' SrcFile)
rb1 Maybe (Position' SrcFile) -> Maybe (Position' SrcFile) -> Bool
forall a. Ord a => a -> a -> Bool
<= Maybe (Position' SrcFile)
ra0 then
(a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [a] -> f [a]
go [a]
as [a]
bs'
else do
[(a, a)] -> f ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [(a
a,a
b)]
if Maybe (Position' SrcFile)
ra0 Maybe (Position' SrcFile) -> Maybe (Position' SrcFile) -> Bool
forall a. Ord a => a -> a -> Bool
< Maybe (Position' SrcFile)
rb0 Bool -> Bool -> Bool
|| (Maybe (Position' SrcFile)
ra0 Maybe (Position' SrcFile) -> Maybe (Position' SrcFile) -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe (Position' SrcFile)
rb0 Bool -> Bool -> Bool
&& Maybe (Position' SrcFile)
ra1 Maybe (Position' SrcFile) -> Maybe (Position' SrcFile) -> Bool
forall a. Ord a => a -> a -> Bool
<= Maybe (Position' SrcFile)
rb1) then
(a
aa -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [a] -> f [a]
go [a]
as' [a]
bs
else
(a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([a] -> [a]) -> f [a] -> f [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [a] -> f [a]
go [a]
as [a]
bs'