{-# language DeriveDataTypeable #-} module Autolib.Pos (Pos, pos, unPos ) where import Autolib.ToDoc import Autolib.Reader import Data.Ix import Data.Hashable import System.Random import Data.Data newtype Pos = Pos { Pos -> Int unPos :: Int } deriving (Pos -> Pos -> Bool (Pos -> Pos -> Bool) -> (Pos -> Pos -> Bool) -> Eq Pos forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Pos -> Pos -> Bool == :: Pos -> Pos -> Bool $c/= :: Pos -> Pos -> Bool /= :: Pos -> Pos -> Bool Eq, Eq Pos Eq Pos => (Pos -> Pos -> Ordering) -> (Pos -> Pos -> Bool) -> (Pos -> Pos -> Bool) -> (Pos -> Pos -> Bool) -> (Pos -> Pos -> Bool) -> (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> Ord Pos Pos -> Pos -> Bool Pos -> Pos -> Ordering Pos -> Pos -> Pos 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 $ccompare :: Pos -> Pos -> Ordering compare :: Pos -> Pos -> Ordering $c< :: Pos -> Pos -> Bool < :: Pos -> Pos -> Bool $c<= :: Pos -> Pos -> Bool <= :: Pos -> Pos -> Bool $c> :: Pos -> Pos -> Bool > :: Pos -> Pos -> Bool $c>= :: Pos -> Pos -> Bool >= :: Pos -> Pos -> Bool $cmax :: Pos -> Pos -> Pos max :: Pos -> Pos -> Pos $cmin :: Pos -> Pos -> Pos min :: Pos -> Pos -> Pos Ord, Int -> Pos Pos -> Int Pos -> [Pos] Pos -> Pos Pos -> Pos -> [Pos] Pos -> Pos -> Pos -> [Pos] (Pos -> Pos) -> (Pos -> Pos) -> (Int -> Pos) -> (Pos -> Int) -> (Pos -> [Pos]) -> (Pos -> Pos -> [Pos]) -> (Pos -> Pos -> [Pos]) -> (Pos -> Pos -> Pos -> [Pos]) -> Enum Pos forall a. (a -> a) -> (a -> a) -> (Int -> a) -> (a -> Int) -> (a -> [a]) -> (a -> a -> [a]) -> (a -> a -> [a]) -> (a -> a -> a -> [a]) -> Enum a $csucc :: Pos -> Pos succ :: Pos -> Pos $cpred :: Pos -> Pos pred :: Pos -> Pos $ctoEnum :: Int -> Pos toEnum :: Int -> Pos $cfromEnum :: Pos -> Int fromEnum :: Pos -> Int $cenumFrom :: Pos -> [Pos] enumFrom :: Pos -> [Pos] $cenumFromThen :: Pos -> Pos -> [Pos] enumFromThen :: Pos -> Pos -> [Pos] $cenumFromTo :: Pos -> Pos -> [Pos] enumFromTo :: Pos -> Pos -> [Pos] $cenumFromThenTo :: Pos -> Pos -> Pos -> [Pos] enumFromThenTo :: Pos -> Pos -> Pos -> [Pos] Enum, Ord Pos Ord Pos => ((Pos, Pos) -> [Pos]) -> ((Pos, Pos) -> Pos -> Int) -> ((Pos, Pos) -> Pos -> Int) -> ((Pos, Pos) -> Pos -> Bool) -> ((Pos, Pos) -> Int) -> ((Pos, Pos) -> Int) -> Ix Pos (Pos, Pos) -> Int (Pos, Pos) -> [Pos] (Pos, Pos) -> Pos -> Bool (Pos, Pos) -> Pos -> Int forall a. Ord a => ((a, a) -> [a]) -> ((a, a) -> a -> Int) -> ((a, a) -> a -> Int) -> ((a, a) -> a -> Bool) -> ((a, a) -> Int) -> ((a, a) -> Int) -> Ix a $crange :: (Pos, Pos) -> [Pos] range :: (Pos, Pos) -> [Pos] $cindex :: (Pos, Pos) -> Pos -> Int index :: (Pos, Pos) -> Pos -> Int $cunsafeIndex :: (Pos, Pos) -> Pos -> Int unsafeIndex :: (Pos, Pos) -> Pos -> Int $cinRange :: (Pos, Pos) -> Pos -> Bool inRange :: (Pos, Pos) -> Pos -> Bool $crangeSize :: (Pos, Pos) -> Int rangeSize :: (Pos, Pos) -> Int $cunsafeRangeSize :: (Pos, Pos) -> Int unsafeRangeSize :: (Pos, Pos) -> Int Ix, Integer -> Pos Pos -> Pos Pos -> Pos -> Pos (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> (Pos -> Pos) -> (Pos -> Pos) -> (Pos -> Pos) -> (Integer -> Pos) -> Num Pos forall a. (a -> a -> a) -> (a -> a -> a) -> (a -> a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> (Integer -> a) -> Num a $c+ :: Pos -> Pos -> Pos + :: Pos -> Pos -> Pos $c- :: Pos -> Pos -> Pos - :: Pos -> Pos -> Pos $c* :: Pos -> Pos -> Pos * :: Pos -> Pos -> Pos $cnegate :: Pos -> Pos negate :: Pos -> Pos $cabs :: Pos -> Pos abs :: Pos -> Pos $csignum :: Pos -> Pos signum :: Pos -> Pos $cfromInteger :: Integer -> Pos fromInteger :: Integer -> Pos Num, Enum Pos Real Pos (Real Pos, Enum Pos) => (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> (Pos -> Pos -> Pos) -> (Pos -> Pos -> (Pos, Pos)) -> (Pos -> Pos -> (Pos, Pos)) -> (Pos -> Integer) -> Integral Pos Pos -> Integer Pos -> Pos -> (Pos, Pos) Pos -> Pos -> Pos forall a. (Real a, Enum a) => (a -> a -> a) -> (a -> a -> a) -> (a -> a -> a) -> (a -> a -> a) -> (a -> a -> (a, a)) -> (a -> a -> (a, a)) -> (a -> Integer) -> Integral a $cquot :: Pos -> Pos -> Pos quot :: Pos -> Pos -> Pos $crem :: Pos -> Pos -> Pos rem :: Pos -> Pos -> Pos $cdiv :: Pos -> Pos -> Pos div :: Pos -> Pos -> Pos $cmod :: Pos -> Pos -> Pos mod :: Pos -> Pos -> Pos $cquotRem :: Pos -> Pos -> (Pos, Pos) quotRem :: Pos -> Pos -> (Pos, Pos) $cdivMod :: Pos -> Pos -> (Pos, Pos) divMod :: Pos -> Pos -> (Pos, Pos) $ctoInteger :: Pos -> Integer toInteger :: Pos -> Integer Integral, Num Pos Ord Pos (Num Pos, Ord Pos) => (Pos -> Rational) -> Real Pos Pos -> Rational forall a. (Num a, Ord a) => (a -> Rational) -> Real a $ctoRational :: Pos -> Rational toRational :: Pos -> Rational Real, Eq Pos Eq Pos => (Int -> Pos -> Int) -> (Pos -> Int) -> Hashable Pos Int -> Pos -> Int Pos -> Int forall a. Eq a => (Int -> a -> Int) -> (a -> Int) -> Hashable a $chashWithSalt :: Int -> Pos -> Int hashWithSalt :: Int -> Pos -> Int $chash :: Pos -> Int hash :: Pos -> Int Hashable,(forall g. RandomGen g => (Pos, Pos) -> g -> (Pos, g)) -> (forall g. RandomGen g => g -> (Pos, g)) -> (forall g. RandomGen g => (Pos, Pos) -> g -> [Pos]) -> (forall g. RandomGen g => g -> [Pos]) -> Random Pos forall g. RandomGen g => g -> [Pos] forall g. RandomGen g => g -> (Pos, g) forall g. RandomGen g => (Pos, Pos) -> g -> [Pos] forall g. RandomGen g => (Pos, Pos) -> g -> (Pos, g) forall a. (forall g. RandomGen g => (a, a) -> g -> (a, g)) -> (forall g. RandomGen g => g -> (a, g)) -> (forall g. RandomGen g => (a, a) -> g -> [a]) -> (forall g. RandomGen g => g -> [a]) -> Random a $crandomR :: forall g. RandomGen g => (Pos, Pos) -> g -> (Pos, g) randomR :: forall g. RandomGen g => (Pos, Pos) -> g -> (Pos, g) $crandom :: forall g. RandomGen g => g -> (Pos, g) random :: forall g. RandomGen g => g -> (Pos, g) $crandomRs :: forall g. RandomGen g => (Pos, Pos) -> g -> [Pos] randomRs :: forall g. RandomGen g => (Pos, Pos) -> g -> [Pos] $crandoms :: forall g. RandomGen g => g -> [Pos] randoms :: forall g. RandomGen g => g -> [Pos] Random, Typeable Pos Typeable Pos => (forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pos -> c Pos) -> (forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pos) -> (Pos -> Constr) -> (Pos -> DataType) -> (forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pos)) -> (forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pos)) -> ((forall b. Data b => b -> b) -> Pos -> Pos) -> (forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r) -> (forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r) -> (forall u. (forall d. Data d => d -> u) -> Pos -> [u]) -> (forall u. Int -> (forall d. Data d => d -> u) -> Pos -> u) -> (forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Pos -> m Pos) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos) -> (forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos) -> Data Pos Pos -> Constr Pos -> DataType (forall b. Data b => b -> b) -> Pos -> Pos 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) -> Pos -> u forall u. (forall d. Data d => d -> u) -> Pos -> [u] forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Pos -> m Pos forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pos forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pos -> c Pos forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pos) forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pos) $cgfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pos -> c Pos gfoldl :: forall (c :: * -> *). (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pos -> c Pos $cgunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pos gunfold :: forall (c :: * -> *). (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pos $ctoConstr :: Pos -> Constr toConstr :: Pos -> Constr $cdataTypeOf :: Pos -> DataType dataTypeOf :: Pos -> DataType $cdataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pos) dataCast1 :: forall (t :: * -> *) (c :: * -> *). Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pos) $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pos) dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *). Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pos) $cgmapT :: (forall b. Data b => b -> b) -> Pos -> Pos gmapT :: (forall b. Data b => b -> b) -> Pos -> Pos $cgmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r gmapQl :: forall r r'. (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r $cgmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Pos -> [u] gmapQ :: forall u. (forall d. Data d => d -> u) -> Pos -> [u] $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pos -> u gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pos -> u $cgmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Pos -> m Pos gmapM :: forall (m :: * -> *). Monad m => (forall d. Data d => d -> m d) -> Pos -> m Pos $cgmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos gmapMp :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos $cgmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos gmapMo :: forall (m :: * -> *). MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos Data) pos :: Int -> Pos pos Int x | Int x Int -> Int -> Bool forall a. Ord a => a -> a -> Bool > Int 0 = Int -> Pos Pos Int x instance ToDoc Pos where toDocPrec :: Int -> Pos -> Doc toDocPrec Int p (Pos Int n) = Int -> Int -> Doc forall a. ToDoc a => Int -> a -> Doc toDocPrec Int p Int n instance Show Pos where showsPrec :: Int -> Pos -> ShowS showsPrec Int p (Pos Int n) = Int -> Int -> ShowS forall a. Show a => Int -> a -> ShowS showsPrec Int p Int n instance Reader Pos where atomic_readerPrec :: Int -> Parser Pos atomic_readerPrec Int p = Integer -> Pos forall a b. (Integral a, Num b) => a -> b fromIntegral (Integer -> Pos) -> ParsecT String () Identity Integer -> Parser Pos forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> do n <- ParsecT String () Identity Integer my_natural if 0 == n then unexpected "must be positive" else return n