Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Grid (cs :: [*]) a = Grid {}
- type family Head xs where ...
- type family Tail xs where ...
- type family CollapseGrid cs a where ...
- type family AllGridSizeKnown cs :: Constraint where ...
- splitVectorBySize :: Int -> Vector a -> [Vector a]
- collapseGrid :: forall cs a. (SListI cs, AllGridSizeKnown cs) => Grid cs a -> CollapseGrid cs a
- gridFromList :: forall cs a. (SListI cs, AllGridSizeKnown cs) => CollapseGrid cs a -> Maybe (Grid cs a)
- transposeGrid :: (IsCoord h, IsCoord w, KnownNat x, KnownNat y, 1 <= y, 1 <= x) => Grid '[w x, h y] a -> Grid '[h y, w x] a
- splitGrid :: forall c cs a. AllSizedKnown cs => Grid (c ': cs) a -> Grid '[c] (Grid cs a)
- combineGrid :: Grid '[c] (Grid cs a) -> Grid (c ': cs) a
- combineHigherDim :: IsCoord c => Grid (c n ': as) x -> Grid (c m ': as) x -> Grid (c (n + m) ': as) x
- dropGrid :: KnownNat n => Proxy n -> Grid '[c m] x -> Grid '[c (m - n)] x
- takeGrid :: KnownNat n => Proxy n -> Grid '[c m] x -> Grid '[c n] x
- splitHigherDim :: forall c as x y z a. (KnownNat x, KnownNat y, y <= x, AllSizedKnown as, IsCoord c) => Grid (c x ': as) a -> (Grid (c y ': as) a, Grid (c z ': as) a)
- 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)
- class ShrinkableGrid (cs :: [*]) (as :: [*]) (bs :: [*]) where
- shrinkGrid :: Coord cs -> Grid as x -> Grid bs x
Documentation
newtype Grid (cs :: [*]) a Source #
A multi dimensional sized grid
Instances
type family Tail xs where ... Source #
All but the first elements of a type level list
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.
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
AllGridSizeKnown '[] = () | |
AllGridSizeKnown cs = (KnownNat (CoordNat (Head cs)), KnownNat (MaxCoordSize (Tail cs)), KnownNat (MaxCoordSize cs), AllGridSizeKnown (Tail cs)) |
splitVectorBySize :: Int -> Vector a -> [Vector a] Source #
Convert a vector into a list of Vector
s, 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 x, KnownNat y, 1 <= y, 1 <= x) => Grid '[w x, h y] a -> Grid '[h y, w x] a Source #
combineHigherDim :: IsCoord c => Grid (c n ': as) x -> Grid (c m ': as) x -> Grid (c (n + m) ': as) x Source #
splitHigherDim :: forall c as x y z a. (KnownNat x, KnownNat y, y <= x, AllSizedKnown as, IsCoord c) => Grid (c x ': as) a -> (Grid (c y ': as) a, Grid (c z ': as) a) 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 #
Instances
ShrinkableGrid ([] :: [Type]) ([] :: [Type]) ([] :: [Type]) Source # | |
Defined in SizedGrid.Grid.Grid | |
(KnownNat z, AllSizedKnown as, IsCoord c, ShrinkableGrid cs as bs, z <= ((x - y) + 1)) => ShrinkableGrid (c x ': cs) (c y ': as) (c z ': bs) Source # | |
Defined in SizedGrid.Grid.Grid |