grids-0.5.0.1

Safe HaskellNone
LanguageHaskell2010

Data.Grid.Internal.Coord

Synopsis

Documentation

newtype Coord (dims :: [Nat]) Source #

The index type for Grids.

Constructors

Coord 

Fields

Instances
IsList (Coord dims) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Associated Types

type Item (Coord dims) :: Type #

Methods

fromList :: [Item (Coord dims)] -> Coord dims #

fromListN :: Int -> [Item (Coord dims)] -> Coord dims #

toList :: Coord dims -> [Item (Coord dims)] #

(KnownNat n, Bounded (Coord ns)) => Bounded (Coord (n ': ns)) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

minBound :: Coord (n ': ns) #

maxBound :: Coord (n ': ns) #

Bounded (Coord ([] :: [Nat])) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

minBound :: Coord [] #

maxBound :: Coord [] #

(KnownNat x, KnownNat y, Sizable (y ': rest), Bounded (Coord rest), Enum (Coord (y ': rest))) => Enum (Coord (x ': (y ': rest))) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

succ :: Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) #

pred :: Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) #

toEnum :: Int -> Coord (x ': (y ': rest)) #

fromEnum :: Coord (x ': (y ': rest)) -> Int #

enumFrom :: Coord (x ': (y ': rest)) -> [Coord (x ': (y ': rest))] #

enumFromThen :: Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) -> [Coord (x ': (y ': rest))] #

enumFromTo :: Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) -> [Coord (x ': (y ': rest))] #

enumFromThenTo :: Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) -> Coord (x ': (y ': rest)) -> [Coord (x ': (y ': rest))] #

KnownNat n => Enum (Coord (n ': ([] :: [Nat]))) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

succ :: Coord (n ': []) -> Coord (n ': []) #

pred :: Coord (n ': []) -> Coord (n ': []) #

toEnum :: Int -> Coord (n ': []) #

fromEnum :: Coord (n ': []) -> Int #

enumFrom :: Coord (n ': []) -> [Coord (n ': [])] #

enumFromThen :: Coord (n ': []) -> Coord (n ': []) -> [Coord (n ': [])] #

enumFromTo :: Coord (n ': []) -> Coord (n ': []) -> [Coord (n ': [])] #

enumFromThenTo :: Coord (n ': []) -> Coord (n ': []) -> Coord (n ': []) -> [Coord (n ': [])] #

Eq (Coord dims) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

(==) :: Coord dims -> Coord dims -> Bool #

(/=) :: Coord dims -> Coord dims -> Bool #

Enum (Coord ns) => Num (Coord ns) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

(+) :: Coord ns -> Coord ns -> Coord ns #

(-) :: Coord ns -> Coord ns -> Coord ns #

(*) :: Coord ns -> Coord ns -> Coord ns #

negate :: Coord ns -> Coord ns #

abs :: Coord ns -> Coord ns #

signum :: Coord ns -> Coord ns #

fromInteger :: Integer -> Coord ns #

Show (Coord dims) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

Methods

showsPrec :: Int -> Coord dims -> ShowS #

show :: Coord dims -> String #

showList :: [Coord dims] -> ShowS #

type Item (Coord dims) Source # 
Instance details

Defined in Data.Grid.Internal.Coord

type Item (Coord dims) = Int

coord :: forall dims. SingI dims => [Int] -> Maybe (Coord dims) Source #

Safely construct a Coord for a given grid size, checking that all indexes are in range

λ> coord @[3, 3] [1, 2]
Just [1, 2]

λ> coord @[3, 3] [3, 3]
Nothing

λ> coord @[3, 3] [1, 2, 3]
Nothing

unconsC :: Coord (n ': ns) -> (Int, Coord ns) Source #

Get the first index from a Coord

appendC :: Coord ns -> Coord ms -> Coord (ns ++ ms) Source #

Append two Coords

pattern (:#) :: Int -> Coord ns -> Coord (n ': ns) Source #

highestIndex :: forall n. KnownNat n => Int Source #

clamp :: Int -> Int -> Int -> Int Source #

clampCoord :: forall dims. SingI dims => Coord dims -> Coord dims Source #

wrapCoord :: forall dims. SingI dims => Coord dims -> Coord dims Source #

coordInBounds :: forall ns. SingI ns => Coord ns -> Bool Source #