sized-grid-0.1.1.5: 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
(AllSizedKnown cs, All IsCoord cs) => IsGrid cs (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Class

Methods

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

asGrid :: Lens' (Grid cs a) (Grid cs a) Source #

asFocusedGrid :: Lens' (Grid cs a) (FocusedGrid cs a) Source #

(AllSizedKnown cs, All IsCoord cs) => Monad (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

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 # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

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

AllSizedKnown cs => Applicative (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

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 # 
Instance details

Defined in SizedGrid.Grid.Grid

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 # 
Instance details

Defined in SizedGrid.Grid.Grid

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

(AllSizedKnown cs, All IsCoord cs) => Distributive (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

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, AllSizedKnown cs) => Representable (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Associated Types

type Rep (Grid cs) :: Type #

Methods

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

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

Eq1 (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

Show1 (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

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 # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

imapped :: IndexedSetter (Coord cs) (Grid cs a) (Grid cs b) a b #

All IsCoord cs => FoldableWithIndex (Coord cs) (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

ifolded :: IndexedFold (Coord cs) (Grid cs a) 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 # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

itraversed :: IndexedTraversal (Coord cs) (Grid cs a) (Grid cs b) a b #

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

Defined in SizedGrid.Grid.Grid

Methods

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

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

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

Defined in SizedGrid.Grid.Grid

Methods

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

show :: Grid cs a -> String #

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

Generic (Grid cs a) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Associated Types

type Rep (Grid cs a) :: Type -> Type #

Methods

from :: Grid cs a -> Rep (Grid cs a) x #

to :: Rep (Grid cs a) x -> Grid cs a #

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

Defined in SizedGrid.Grid.Grid

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 # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

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

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

type Rep (Grid cs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

type Rep (Grid cs) = Coord cs
type Rep (Grid cs a) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

type Rep (Grid cs a) = D1 (MetaData "Grid" "SizedGrid.Grid.Grid" "sized-grid-0.1.1.5-KU5jkLUCL2P2O7tFE4dPdR" True) (C1 (MetaCons "Grid" PrefixI True) (S1 (MetaSel (Just "unGrid") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector a))))

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

transposeGrid :: (IsCoord h, IsCoord w, KnownNat (MaxCoordSize '[w, h]), KnownNat (MaxCoordSize '[h, w])) => Grid '[w, h] a -> Grid '[h, w] a Source #

splitGrid :: forall c cs a. AllSizedKnown cs => Grid (c ': cs) a -> Grid '[c] (Grid cs a) Source #

combineGrid :: Grid '[c] (Grid cs a) -> Grid (c ': cs) a Source #

combineHigherDim :: (CoordFromNat a ~ CoordFromNat b, c ~ CoordFromNat a ((+) (CoordSized a) (CoordSized b))) => Grid (a ': as) x -> Grid (b ': as) x -> Grid (c ': as) x Source #

dropGrid :: KnownNat n => Proxy n -> Grid '[c] x -> Grid '[CoordFromNat c (CoordSized c - n)] x Source #

takeGrid :: KnownNat n => Proxy n -> Grid '[c] x -> Grid '[CoordFromNat c n] x Source #

splitHigherDim :: forall a b c as x. (KnownNat (CoordSized b), c ~ CoordFromNat a (CoordSized a - CoordSized b), CoordSized b <= CoordSized a, AllSizedKnown as) => Grid (a ': as) x -> (Grid (b ': as) x, Grid (c ': as) x) Source #

mapLowerDim :: forall as bs x y c f. (AllSizedKnown as, Applicative f) => (Grid as x -> f (Grid bs y)) -> Grid (c ': as) x -> f (Grid (c ': bs) y) Source #

class ShrinkableGrid (cs :: [*]) (as :: [*]) (bs :: [*]) where Source #

Methods

shrinkGrid :: Coord cs -> Grid as x -> Grid bs x Source #

Instances
ShrinkableGrid ([] :: [Type]) ([] :: [Type]) ([] :: [Type]) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

shrinkGrid :: Coord [] -> Grid [] x -> Grid [] x Source #

(KnownNat (CoordSized b), AllSizedKnown as, IsCoord c, ShrinkableGrid cs as bs, CoordFromNat b ~ CoordFromNat a, CoordSized b <= ((CoordSized a - CoordSized c) + 1)) => ShrinkableGrid (c ': cs) (a ': as) (b ': bs) Source # 
Instance details

Defined in SizedGrid.Grid.Grid

Methods

shrinkGrid :: Coord (c ': cs) -> Grid (a ': as) x -> Grid (b ': bs) x Source #