sized-grid-0.1.0.0: Multidimensional grids with sized specified at compile time

Safe HaskellNone
LanguageHaskell2010

SizedGrid.Coord

Synopsis

Documentation

type family Length cs where ... Source #

Length of a type level list

Equations

Length '[] = 0 
Length (c ': cs) = (+) 1 (Length cs) 

newtype Coord cs Source #

A multideminsion coordinate

Constructors

Coord 

Fields

Instances

All * Eq cs => Eq (Coord cs) Source # 

Methods

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

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

(All * Eq cs, All * Ord cs) => Ord (Coord cs) Source # 

Methods

compare :: Coord cs -> Coord cs -> Ordering #

(<) :: Coord cs -> Coord cs -> Bool #

(<=) :: Coord cs -> Coord cs -> Bool #

(>) :: Coord cs -> Coord cs -> Bool #

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

max :: Coord cs -> Coord cs -> Coord cs #

min :: Coord cs -> Coord cs -> Coord cs #

All * Show cs => Show (Coord cs) Source # 

Methods

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

show :: Coord cs -> String #

showList :: [Coord cs] -> ShowS #

Generic (Coord cs) Source # 

Associated Types

type Rep (Coord cs) :: * -> * #

Methods

from :: Coord cs -> Rep (Coord cs) x #

to :: Rep (Coord cs) x -> Coord cs #

All * Semigroup cs => Semigroup (Coord cs) Source # 

Methods

(<>) :: Coord cs -> Coord cs -> Coord cs #

sconcat :: NonEmpty (Coord cs) -> Coord cs #

stimes :: Integral b => b -> Coord cs -> Coord cs #

(All * Semigroup cs, All * Monoid cs) => Monoid (Coord cs) Source # 

Methods

mempty :: Coord cs #

mappend :: Coord cs -> Coord cs -> Coord cs #

mconcat :: [Coord cs] -> Coord cs #

All * Random cs => Random (Coord cs) Source # 

Methods

randomR :: RandomGen g => (Coord cs, Coord cs) -> g -> (Coord cs, g) #

random :: RandomGen g => g -> (Coord cs, g) #

randomRs :: RandomGen g => (Coord cs, Coord cs) -> g -> [Coord cs] #

randoms :: RandomGen g => g -> [Coord cs] #

randomRIO :: (Coord cs, Coord cs) -> IO (Coord cs) #

randomIO :: IO (Coord cs) #

All * ToJSON cs => ToJSON (Coord cs) Source # 

Methods

toJSON :: Coord cs -> Value

toEncoding :: Coord cs -> Encoding

toJSONList :: [Coord cs] -> Value

toEncodingList :: [Coord cs] -> Encoding

All * FromJSON cs => FromJSON (Coord cs) Source # 

Methods

parseJSON :: Value -> Parser (Coord cs)

parseJSONList :: Value -> Parser [Coord cs]

All * AdditiveGroup cs => AdditiveGroup (Coord cs) Source # 

Methods

zeroV :: Coord cs

(^+^) :: Coord cs -> Coord cs -> Coord cs

negateV :: Coord cs -> Coord cs

(^-^) :: Coord cs -> Coord cs -> Coord cs

(All * AffineSpace cs, AdditiveGroup (CoordDiff * cs), IsProductType (CoordDiff * cs) (MapDiff cs)) => AffineSpace (Coord cs) Source # 

Associated Types

type Diff (Coord cs) :: *

Methods

(.-.) :: Coord cs -> Coord cs -> Diff (Coord cs)

(.+^) :: Coord cs -> Diff (Coord cs) -> Coord cs

All * IsCoord cs => TraversableWithIndex (Coord cs) (Grid cs) 

Methods

itraverse :: Applicative f => (Coord cs -> a -> f b) -> Grid cs a -> f (Grid cs b)

itraversed :: (Indexable (Coord cs) p, Applicative f) => p a (f b) -> Grid cs a -> f (Grid cs b)

All * IsCoord cs => FunctorWithIndex (Coord cs) (Grid cs) 

Methods

imap :: (Coord cs -> a -> b) -> Grid cs a -> Grid cs b

imapped :: (Indexable (Coord cs) p, Settable f) => p a (f b) -> Grid cs a -> f (Grid cs b)

All * IsCoord cs => FoldableWithIndex (Coord cs) (Grid cs) 

Methods

ifoldMap :: Monoid m => (Coord cs -> a -> m) -> Grid cs a -> m

ifolded :: (Indexable (Coord cs) p, Contravariant f, Applicative f) => p a (f a) -> Grid cs a -> f (Grid cs a)

ifoldr :: (Coord cs -> a -> b -> b) -> b -> Grid cs a -> b

ifoldl :: (Coord cs -> b -> a -> b) -> b -> Grid cs a -> b

ifoldr' :: (Coord cs -> a -> b -> b) -> b -> Grid cs a -> b

ifoldl' :: (Coord cs -> b -> a -> b) -> b -> Grid cs a -> b

(KnownNat (MaxCoordSize * cs), All * IsCoord cs, All * Monoid cs, All * Semigroup cs, SListI * cs) => ComonadStore (Coord cs) (FocusedGrid cs) 

Methods

pos :: FocusedGrid cs a -> Coord cs

peek :: Coord cs -> FocusedGrid cs a -> a

peeks :: (Coord cs -> Coord cs) -> FocusedGrid cs a -> a

seek :: Coord cs -> FocusedGrid cs a -> FocusedGrid cs a

seeks :: (Coord cs -> Coord cs) -> FocusedGrid cs a -> FocusedGrid cs a

experiment :: Functor f => (Coord cs -> f (Coord cs)) -> FocusedGrid cs a -> f a

type Rep (Coord cs) Source # 
type Rep (Coord cs) = D1 (MetaData "Coord" "SizedGrid.Coord" "sized-grid-0.1.0.0-LlpdzwKLcdEJScOvvDkGY1" True) (C1 (MetaCons "Coord" PrefixI True) (S1 (MetaSel (Just Symbol "unCoord") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NP * I cs))))
type Diff (Coord cs) Source # 
type Diff (Coord cs) = CoordDiff * cs

type family CoordDiff (cs :: [k]) :: * Source #

The type of difference between two coords. A n-dimensional coord should have a Diff of an n-tuple of Integers. We use Identity and our 1-tuple. Unfortuantly, each instance is manual at the moment.

Instances

type CoordDiff k ([] k) Source # 
type CoordDiff k ([] k) = ()
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ((:) * e ((:) * f ([] *))))))) Source # 
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ((:) * e ((:) * f ([] *))))))) = (Diff a, Diff b, Diff c, Diff d, Diff e, Diff f)
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ((:) * e ([] *)))))) Source # 
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ((:) * e ([] *)))))) = (Diff a, Diff b, Diff c, Diff d, Diff e)
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ([] *))))) Source # 
type CoordDiff * ((:) * a ((:) * b ((:) * c ((:) * d ([] *))))) = (Diff a, Diff b, Diff c, Diff d)
type CoordDiff * ((:) * a ((:) * b ((:) * c ([] *)))) Source # 
type CoordDiff * ((:) * a ((:) * b ((:) * c ([] *)))) = (Diff a, Diff b, Diff c)
type CoordDiff * ((:) * a ((:) * b ([] *))) Source # 
type CoordDiff * ((:) * a ((:) * b ([] *))) = (Diff a, Diff b)
type CoordDiff * ((:) * a ([] *)) Source # 
type CoordDiff * ((:) * a ([] *)) = Identity (Diff a)

type family MapDiff xs where ... Source #

Apply Diff to each element of a type level list. This is required as type families can't be partially applied.

Equations

MapDiff '[] = '[] 
MapDiff (x ': xs) = Diff x ': MapDiff xs 

allCoord :: forall cs. All IsCoord cs => [Coord cs] Source #

Generate all possible coords in order

type family MaxCoordSize (cs :: [k]) :: Nat where ... Source #

The number of elements a coord can have. This is equal to the product of the CoordSized of each element

Equations

MaxCoordSize '[] = 1 
MaxCoordSize (c ': cs) = CoordSized c * MaxCoordSize cs 

coordPosition :: All IsCoord cs => Coord cs -> Int Source #

Convert a Coord to its position in a vector

type family AllDiffSame a xs :: Constraint where ... Source #

All Diffs of the members of the list must be equal

Equations

AllDiffSame _ '[] = () 
AllDiffSame a (x ': xs) = (Diff x ~ a, AllDiffSame a xs) 

moorePoints :: forall a cs. (Enum a, Num a, AllDiffSame a cs, All AffineSpace cs) => a -> Coord cs -> [Coord cs] Source #

Calculate the Moore neighbourhood around a point. Includes the center

vonNeumanPoints :: forall a cs. (Enum a, Num a, Ord a, All Integral (MapDiff cs), AllDiffSame a cs, All AffineSpace cs, Ord (CoordDiff cs), IsProductType (CoordDiff cs) (MapDiff cs), AdditiveGroup (CoordDiff cs)) => a -> Coord cs -> [Coord cs] Source #

Calculate the von Neuman neighbourhood around a point. Includes the center