Safe Haskell | None |
---|---|
Language | Haskell2010 |
- 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)
Documentation
A multi dimensional sized grid
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 (CoordSized (Head cs)), KnownNat (MaxCoordSize (Tail 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