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

Safe HaskellNone
LanguageHaskell2010

SizedGrid.Grid.Grid

Synopsis

Documentation

newtype Grid (cs :: [*]) a Source #

A multi dimensional sized grid

Constructors

Grid 

Fields

Instances

(KnownNat (MaxCoordSize * cs), All * Semigroup cs, All * Monoid cs, All * IsCoord cs) => IsGrid cs (Grid cs) Source # 

Methods

gridIndex :: Coord cs -> Lens' (Grid cs a) a Source #

asGrid :: Functor f => (Grid cs a -> f (Grid cs a)) -> Grid cs a -> f (Grid cs a) Source #

asFocusedGrid :: Functor f => (FocusedGrid cs a -> f (FocusedGrid cs a)) -> Grid cs a -> f (Grid cs a) Source #

(KnownNat (MaxCoordSize * cs), All * IsCoord cs) => Monad (Grid cs) Source # 

Methods

(>>=) :: Grid cs a -> (a -> Grid cs b) -> Grid cs b #

(>>) :: Grid cs a -> Grid cs b -> Grid cs b #

return :: a -> Grid cs a #

fail :: String -> Grid cs a #

Functor (Grid cs) Source # 

Methods

fmap :: (a -> b) -> Grid cs a -> Grid cs b #

(<$) :: a -> Grid cs b -> Grid cs a #

KnownNat (MaxCoordSize * cs) => Applicative (Grid cs) Source # 

Methods

pure :: a -> Grid cs a #

(<*>) :: Grid cs (a -> b) -> Grid cs a -> Grid cs b #

liftA2 :: (a -> b -> c) -> Grid cs a -> Grid cs b -> Grid cs c #

(*>) :: Grid cs a -> Grid cs b -> Grid cs b #

(<*) :: Grid cs a -> Grid cs b -> Grid cs a #

Foldable (Grid cs) Source # 

Methods

fold :: Monoid m => Grid cs m -> m #

foldMap :: Monoid m => (a -> m) -> Grid cs a -> m #

foldr :: (a -> b -> b) -> b -> Grid cs a -> b #

foldr' :: (a -> b -> b) -> b -> Grid cs a -> b #

foldl :: (b -> a -> b) -> b -> Grid cs a -> b #

foldl' :: (b -> a -> b) -> b -> Grid cs a -> b #

foldr1 :: (a -> a -> a) -> Grid cs a -> a #

foldl1 :: (a -> a -> a) -> Grid cs a -> a #

toList :: Grid cs a -> [a] #

null :: Grid cs a -> Bool #

length :: Grid cs a -> Int #

elem :: Eq a => a -> Grid cs a -> Bool #

maximum :: Ord a => Grid cs a -> a #

minimum :: Ord a => Grid cs a -> a #

sum :: Num a => Grid cs a -> a #

product :: Num a => Grid cs a -> a #

Traversable (Grid cs) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Grid cs a -> f (Grid cs b) #

sequenceA :: Applicative f => Grid cs (f a) -> f (Grid cs a) #

mapM :: Monad m => (a -> m b) -> Grid cs a -> m (Grid cs b) #

sequence :: Monad m => Grid cs (m a) -> m (Grid cs a) #

(KnownNat (MaxCoordSize * cs), All * IsCoord cs) => Distributive (Grid cs) Source # 

Methods

distribute :: Functor f => f (Grid cs a) -> Grid cs (f a) #

collect :: Functor f => (a -> Grid cs b) -> f a -> Grid cs (f b) #

distributeM :: Monad m => m (Grid cs a) -> Grid cs (m a) #

collectM :: Monad m => (a -> Grid cs b) -> m a -> Grid cs (m b) #

(All * IsCoord cs, KnownNat (MaxCoordSize * cs)) => Representable (Grid cs) Source # 

Associated Types

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

Methods

tabulate :: (Rep (Grid cs) -> a) -> Grid cs a #

index :: Grid cs a -> Rep (Grid cs) -> a #

Eq1 (Grid cs) Source # 

Methods

liftEq :: (a -> b -> Bool) -> Grid cs a -> Grid cs b -> Bool #

Show1 (Grid cs) Source # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Grid cs a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Grid cs a] -> ShowS #

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

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) Source # 

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 #

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

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) #

Eq a => Eq (Grid cs a) Source # 

Methods

(==) :: Grid cs a -> Grid cs a -> Bool #

(/=) :: Grid cs a -> Grid cs a -> Bool #

Show a => Show (Grid cs a) Source # 

Methods

showsPrec :: Int -> Grid cs a -> ShowS #

show :: Grid cs a -> String #

showList :: [Grid cs a] -> ShowS #

(AllGridSizeKnown cs, ToJSON a, SListI * cs) => ToJSON (Grid cs a) Source # 

Methods

toJSON :: Grid cs a -> Value #

toEncoding :: Grid cs a -> Encoding #

toJSONList :: [Grid cs a] -> Value #

toEncodingList :: [Grid cs a] -> Encoding #

(All * IsCoord cs, FromJSON a) => FromJSON (Grid cs a) Source # 

Methods

parseJSON :: Value -> Parser (Grid cs a) #

parseJSONList :: Value -> Parser [Grid cs a] #

type Rep (Grid cs) Source # 
type Rep (Grid cs) = Coord cs

type family Head xs where ... Source #

The first element of a type level list

Equations

Head (x ': xs) = x 

type family Tail xs where ... Source #

All but the first elements of a type level list

Equations

Tail (x ': xs) = xs 

type family CollapseGrid cs a where ... Source #

Given a grid type, give back a series of nested lists repesenting the grid. The lists will have a number of layers equal to the dimensionality.

Equations

CollapseGrid '[] a = a 
CollapseGrid (c ': cs) a = [CollapseGrid cs a] 

type family AllGridSizeKnown cs :: Constraint where ... Source #

A Constraint that all grid sizes are instances of KnownNat

splitVectorBySize :: Int -> Vector a -> [Vector a] Source #

Convert a vector into a list of Vectors, where all the elements of the list have the given size.

collapseGrid :: forall cs a. (SListI cs, AllGridSizeKnown cs) => Grid cs a -> CollapseGrid cs a Source #

Convert a grid to a series of nested lists. This removes type level information, but it is sometimes easier to work with lists

gridFromList :: forall cs a. (SListI cs, AllGridSizeKnown cs) => CollapseGrid cs a -> Maybe (Grid cs a) Source #

Convert a series of nested lists to a grid. If the size of the grid does not match the size of lists this will be Nothing