-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Arbitrary sized type-safe grids with useful combinators @package grids @version 0.5.0.0 module Data.Grid.Internal.Errors type family (b :: Bool) ?! (e :: ErrorMessage) :: Constraint infixr 1 ?! -- | A description of a custom type error. data ErrorMessage -- | Show the text as is. [Text] :: () => Symbol -> ErrorMessage -- | Pretty print the type. ShowType :: k -> ErrorMessage [ShowType] :: forall t. () => t -> ErrorMessage -- | Put two pieces of error message next to each other. [:<>:] :: () => ErrorMessage -> ErrorMessage -> ErrorMessage -- | Stack two pieces of error message on top of each other. [:$$:] :: () => ErrorMessage -> ErrorMessage -> ErrorMessage infixl 6 :<>: infixl 5 :$$: module Data.Grid.Internal.Nest module Data.Grid.Internal.NestedLists -- | Computes the level of nesting requried to represent a given grid -- dimensionality as a nested list -- --
--   NestedLists [2, 3] Int == [[Int]]
--   NestedLists [2, 3, 4] Int == [[[Int]]]
--   
type family NestedLists (dims :: [Nat]) a chunkVector :: forall a. Int -> Vector a -> [Vector a] -- | Represents valid dimensionalities. All non empty lists of Nats have an -- instance class Sizable (dims :: [Nat]) nestLists :: Sizable dims => Proxy dims -> Vector a -> NestedLists dims a unNestLists :: Sizable dims => Proxy dims -> NestedLists dims a -> [a] -- | Get the total size of a Grid of the given dimensions -- --
--   gridSize (Proxy @'[2, 2]) == 4
--   
gridSize :: Sizable dims => Proxy dims -> Int instance GHC.TypeNats.KnownNat x => Data.Grid.Internal.NestedLists.Sizable '[x] instance (GHC.TypeNats.KnownNat x, Data.Grid.Internal.NestedLists.Sizable (y : xs)) => Data.Grid.Internal.NestedLists.Sizable (x : y : xs) module Data.Grid.Internal.Coord -- | The index type for Grids. newtype Coord (dims :: [Nat]) Coord :: [Int] -> Coord [unCoord] :: Coord -> [Int] -- | Safely construct a Coord for a given grid size, checking that -- all indexes are in range -- --
--   λ> coord @[3, 3] [1, 2]
--   Just [1, 2]
--   
--   λ> coord @[3, 3] [3, 3]
--   Nothing
--   
--   λ> coord @[3, 3] [1, 2, 3]
--   Nothing
--   
coord :: forall dims. SingI dims => [Int] -> Maybe (Coord dims) -- | Get the first index from a Coord unconsC :: Coord (n : ns) -> (Int, Coord ns) -- | Append two Coords appendC :: Coord ns -> Coord ms -> Coord (ns ++ ms) pattern (:#) :: Int -> Coord ns -> Coord (n : ns) highestIndex :: forall n. KnownNat n => Int clamp :: Int -> Int -> Int -> Int clampCoord :: forall dims. SingI dims => Coord dims -> Coord dims wrapCoord :: forall dims. SingI dims => Coord dims -> Coord dims coerceCoordDims :: Coord ns -> Coord ms coordInBounds :: forall ns. SingI ns => Coord ns -> Bool instance GHC.Show.Show (Data.Grid.Internal.Coord.Coord dims) instance GHC.Classes.Eq (Data.Grid.Internal.Coord.Coord dims) instance GHC.Exts.IsList (Data.Grid.Internal.Coord.Coord dims) instance GHC.Enum.Enum (Data.Grid.Internal.Coord.Coord ns) => GHC.Num.Num (Data.Grid.Internal.Coord.Coord ns) instance GHC.Enum.Bounded (Data.Grid.Internal.Coord.Coord '[]) instance (GHC.TypeNats.KnownNat n, GHC.Enum.Bounded (Data.Grid.Internal.Coord.Coord ns)) => GHC.Enum.Bounded (Data.Grid.Internal.Coord.Coord (n : ns)) instance GHC.TypeNats.KnownNat n => GHC.Enum.Enum (Data.Grid.Internal.Coord.Coord '[n]) instance (GHC.TypeNats.KnownNat x, GHC.TypeNats.KnownNat y, Data.Grid.Internal.NestedLists.Sizable (y : rest), GHC.Enum.Bounded (Data.Grid.Internal.Coord.Coord rest), GHC.Enum.Enum (Data.Grid.Internal.Coord.Coord (y : rest))) => GHC.Enum.Enum (Data.Grid.Internal.Coord.Coord (x : y : rest)) module Data.Grid.Internal.Pretty class PrettyList l prettyList :: PrettyList l => l -> String instance GHC.Show.Show a => Data.Grid.Internal.Pretty.PrettyList [a] instance GHC.Show.Show a => Data.Grid.Internal.Pretty.PrettyList [[a]] instance GHC.Show.Show a => Data.Grid.Internal.Pretty.PrettyList [[[a]]] module Data.Grid.Internal.Grid -- | An grid of arbitrary dimensions. -- -- e.g. a Grid [2, 3] Int might look like: -- --
--   generate id :: Grid [2, 3] Int
--   fromNestedLists [[0,1,2],
--                    [3,4,5]]
--   
newtype Grid (dims :: [Nat]) a Grid :: Vector a -> Grid a [toVector] :: Grid a -> Vector a type IsGrid dims = (AllC KnownNat dims, SingI dims, Sizable dims, Representable (Grid dims), Enum (Coord dims), Bounded (Coord dims), Neighboring dims) -- | The index type for Grids. data Coord (dims :: [Nat]) -- | Computes the level of nesting requried to represent a given grid -- dimensionality as a nested list -- --
--   NestedLists [2, 3] Int == [[Int]]
--   NestedLists [2, 3, 4] Int == [[[Int]]]
--   
type family NestedLists (dims :: [Nat]) a -- | Build a grid by selecting an element for each element generate :: forall dims a. IsGrid dims => (Int -> a) -> Grid dims a -- | Turn a grid into a nested list structure. List nesting increases for -- each dimension -- --
--   toNestedLists (G.generate id :: Grid [2, 3] Int)
--   [[0,1,2],[3,4,5]]
--   
toNestedLists :: forall dims a. IsGrid dims => Grid dims a -> NestedLists dims a -- | Turn a nested list structure into a Grid if the list is well formed. -- Required list nesting increases for each dimension -- --
--   fromNestedLists [[0,1,2],[3,4,5]] :: Maybe (Grid [2, 3] Int)
--   Just (Grid [[0,1,2],[3,4,5]])
--   fromNestedLists [[0],[1,2]] :: Maybe (Grid [2, 3] Int)
--   Nothing
--   
fromNestedLists :: forall dims a. IsGrid dims => NestedLists dims a -> Maybe (Grid dims a) -- | Partial variant of fromNestedLists which errors on malformed -- input fromNestedLists' :: forall dims a. IsGrid dims => NestedLists dims a -> Grid dims a -- | Convert a list into a Grid or fail if not provided the correct number -- of elements -- --
--   G.fromList [0, 1, 2, 3, 4, 5] :: Maybe (Grid [2, 3] Int)
--   Just (Grid [[0,1,2],[3,4,5]])
--   G.fromList [0, 1, 2, 3] :: Maybe (Grid [2, 3] Int)
--   Nothing
--   
fromList :: forall dims a. IsGrid dims => [a] -> Maybe (Grid dims a) -- | Partial variant of fromList which errors on malformed input fromList' :: forall dims a. IsGrid dims => [a] -> Grid dims a -- | Update elements of a grid (//) :: forall dims a. IsGrid dims => Grid dims a -> [(Coord dims, a)] -> Grid dims a class Neighboring dims neighborCoords :: Neighboring dims => Grid dims (Coord dims) -- | The inverse of splitGrid, joinGrid will nest a grid from: > -- Grid outer (Grid inner a) -> Grid (outer ++ inner) a -- -- For example, you can nest a simple 3x3 from smaller [3] grids as -- follows: -- --
--   joinGrid (myGrid :: Grid [3] (Grid [3] a)) :: Grid '[3, 3] a
--   
joinGrid :: Grid dims (Grid ns a) -> Grid (dims ++ ns) a -- | The inverse of joinGrid, splitGrid outerDims innerDims -- will un-nest a grid from: > Grid (outer ++ inner) a -> Grid -- outer (Grid inner a) -- -- For example, you can unnest a simple 3x3 as follows: -- --
--   splitGrid @'[3] @'[3] myGrid :: Grid '[3] (Grid [3] a)
--   
splitGrid :: forall outer inner a from. (IsGrid from, IsGrid inner, IsGrid outer, NestedLists from a ~ NestedLists outer (NestedLists inner a)) => Grid from a -> Grid outer (Grid inner a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Grid.Internal.Grid.Grid dims a) instance Data.Traversable.Traversable (Data.Grid.Internal.Grid.Grid dims) instance Data.Foldable.Foldable (Data.Grid.Internal.Grid.Grid dims) instance GHC.Base.Functor (Data.Grid.Internal.Grid.Grid dims) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Grid.Internal.Grid.Grid dims a) instance (Data.Grid.Internal.Pretty.PrettyList (Data.Grid.Internal.NestedLists.NestedLists dims a), Data.Grid.Internal.Grid.IsGrid dims, GHC.Show.Show (Data.Grid.Internal.NestedLists.NestedLists dims a)) => GHC.Show.Show (Data.Grid.Internal.Grid.Grid dims a) instance (Data.Grid.Internal.Grid.IsGrid dims, GHC.Base.Semigroup a) => GHC.Base.Semigroup (Data.Grid.Internal.Grid.Grid dims a) instance (Data.Grid.Internal.Grid.IsGrid dims, GHC.Base.Monoid a) => GHC.Base.Monoid (Data.Grid.Internal.Grid.Grid dims a) instance Data.Grid.Internal.Grid.IsGrid dims => GHC.Base.Applicative (Data.Grid.Internal.Grid.Grid dims) instance Data.Grid.Internal.Grid.IsGrid dims => Data.Distributive.Distributive (Data.Grid.Internal.Grid.Grid dims) instance Data.Grid.Internal.Grid.IsGrid dims => Data.Functor.Rep.Representable (Data.Grid.Internal.Grid.Grid dims) instance (GHC.Num.Num n, Data.Grid.Internal.Grid.IsGrid dims) => GHC.Num.Num (Data.Grid.Internal.Grid.Grid dims n) instance Data.Grid.Internal.Grid.IsGrid '[n] => Data.Grid.Internal.Grid.Neighboring '[n] instance (GHC.TypeNats.KnownNat n, Data.Grid.Internal.Grid.Neighboring ns) => Data.Grid.Internal.Grid.Neighboring (n : ns) module Data.Grid.Internal.Lens type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t type Lens' s a = Lens s s a a lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b -- | Focus an element of a Grid given its Coord cell :: forall dims a. IsGrid dims => Coord dims -> Lens' (Grid dims a) a module Data.Grid.Internal.Convolution -- | Perform a computation based on the context surrounding a cell Good for -- doing things like Linear Image Filters (e.g. gaussian blur) or -- simulating Cellular Automata (e.g. Conway's game of life) -- -- This function accepts a function which indicates what to do with -- 'out-of-bounds' indexes, clampWindow, wrapWindow and -- safeWindow are examples. -- -- It also acccepts a transformation function which operates over the -- functor created by the first parameter and collapses it down to a new -- value for the cell at that position. -- -- This function is best used with Type Applications to denote the -- desired window size; the Grid passed to the given function contains -- the current cell (in the middle) and all the surrounding cells. -- -- Here's an example of computing the average of all neighboring cells, -- repeating values at the edge of the grid when indexes are out of -- bounds (using clampWindow) -- --
--   gaussian :: (IsGrid dims) => Grid dims Double -> Grid dims Double
--   gaussian = autoConvolute clampBounds avg
--    where
--     avg :: Grid '[3, 3] Double -> Double
--     avg g = sum g / fromIntegral (length g)
--   
autoConvolute :: forall window dims f a b. (IsGrid dims, IsGrid window, Functor f) => (Grid window (Coord dims) -> f (Coord dims)) -> (f a -> b) -> Grid dims a -> Grid dims b -- | This is a fully generic version of autoConvolute which allows -- the user to provide a function which builds a context from the current -- coord, then provides a collapsing function over the same functor. convolute :: forall dims f a b. (Functor f, IsGrid dims) => (Coord dims -> f (Coord dims)) -> (f a -> b) -> Grid dims a -> Grid dims b -- | Use with autoConvolute; Clamp out-of-bounds coordinates to the -- nearest in-bounds coord. clampBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> f (Coord dims) -- | Use with autoConvolute; Wrap out-of-bounds coordinates pac-man -- style to the other side of the grid wrapBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> f (Coord dims) -- | Use with autoConvolute; Out of bounds coords become -- Nothing omitBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> Compose f Maybe (Coord dims) -- | Given a coordinate generate a grid of size window filled with -- coordinates surrounding the given coord. Mostly used internally window :: forall window dims. IsGrid window => Coord dims -> Grid window (Coord dims) class Neighboring dims module Data.Grid.Internal.Shapes partitionFocus :: forall window a. (Centered window, IsGrid window) => Grid window a -> (a, Grid window (Maybe a)) centerCoord :: Centered dims => Coord dims class Centered (dims :: [Nat]) instance (Data.Grid.Internal.Shapes.OddC x, GHC.TypeNats.KnownNat x) => Data.Grid.Internal.Shapes.Centered '[x] instance (Data.Grid.Internal.Shapes.OddC x, GHC.TypeNats.KnownNat x, Data.Grid.Internal.Shapes.Centered xs) => Data.Grid.Internal.Shapes.Centered (x : xs) module Data.Grid.Internal.Transpose type family Permuted (key :: [Nat]) (from :: [Nat]) :: [Nat] type ValidPermutation key from = (Sort key == EnumFromTo 0 (Length from - 1)) ?! ( 'Text "Malformed permutation hint: " :<>: 'ShowType key :$$: 'Text "When permuting matrix of size: " :<>: 'ShowType from :$$: 'Text "Key must be a permutation of " :<>: 'ShowType (EnumFromTo 0 (Length from - 1)) :$$: 'Text "e.g. the identity permutation for 2x2 is @[0, 1]" :$$: 'Text "e.g. matrix transpose for 2x2 is @[1, 0]") -- | Permute dimensions of a Grid. This is similar to MatLab's -- permute function -- -- permute requires a type application containing a permutation -- pattern; The pattern is a re-ordering of the list [0..n] -- which represents the new dimension order. For example the permutation -- pattern [1, 2, 0] when applied to the dimensions [4, 5, -- 6] results in the dimensions [5, 6, 4]. -- -- For 2 dimensional matrixes, a permutation using [1, 0] is -- simply a matrix transpose -- --
--   λ> small
--   fromNestedLists
--     [[0,1,2]
--     ,[3,4,5]
--     ,[6,7,8]]
--   
--   λ> permute @[1, 0] small
--   fromNestedLists
--     [[0,3,6]
--     ,[1,4,7]
--     ,[2,5,8]]
--   
permute :: forall (key :: [Nat]) from a invertedKey. (SingI invertedKey, invertedKey ~ InvertKey (EnumFromTo 0 (Length from - 1)) key, ValidPermutation key from, IsGrid from, IsGrid (Permuted key from)) => Grid from a -> Grid (Permuted key from) a -- | Permute the dimensions of a coordinate according to a permutation -- pattern. see permute regarding permutation patterns permuteCoord :: forall (key :: [Nat]) to from. SingI key => Coord from -> Coord to -- | Transpose a 2 dimensional matrix. Equivalent to: -- --
--   permute @[1, 0]
--   
transpose :: (IsGrid '[x, y], IsGrid '[y, x]) => Grid '[x, y] a -> Grid '[y, x] a -- | Get the inverse of a permutation pattern, used internally type family InvertKey ref key :: [Nat] module Data.Grid -- | An grid of arbitrary dimensions. -- -- e.g. a Grid [2, 3] Int might look like: -- --
--   generate id :: Grid [2, 3] Int
--   fromNestedLists [[0,1,2],
--                    [3,4,5]]
--   
newtype Grid (dims :: [Nat]) a Grid :: Vector a -> Grid a [toVector] :: Grid a -> Vector a -- | Build a grid by selecting an element for each element generate :: forall dims a. IsGrid dims => (Int -> a) -> Grid dims a -- |
--   fmap f . tabulatetabulate . fmap f
--   
-- -- If no definition is provided, this will default to gtabulate. tabulate :: Representable f => (Rep f -> a) -> f a -- | Turn a nested list structure into a Grid if the list is well formed. -- Required list nesting increases for each dimension -- --
--   fromNestedLists [[0,1,2],[3,4,5]] :: Maybe (Grid [2, 3] Int)
--   Just (Grid [[0,1,2],[3,4,5]])
--   fromNestedLists [[0],[1,2]] :: Maybe (Grid [2, 3] Int)
--   Nothing
--   
fromNestedLists :: forall dims a. IsGrid dims => NestedLists dims a -> Maybe (Grid dims a) -- | Partial variant of fromNestedLists which errors on malformed -- input fromNestedLists' :: forall dims a. IsGrid dims => NestedLists dims a -> Grid dims a -- | Convert a list into a Grid or fail if not provided the correct number -- of elements -- --
--   G.fromList [0, 1, 2, 3, 4, 5] :: Maybe (Grid [2, 3] Int)
--   Just (Grid [[0,1,2],[3,4,5]])
--   G.fromList [0, 1, 2, 3] :: Maybe (Grid [2, 3] Int)
--   Nothing
--   
fromList :: forall dims a. IsGrid dims => [a] -> Maybe (Grid dims a) -- | Partial variant of fromList which errors on malformed input fromList' :: forall dims a. IsGrid dims => [a] -> Grid dims a -- | Turn a grid into a nested list structure. List nesting increases for -- each dimension -- --
--   toNestedLists (G.generate id :: Grid [2, 3] Int)
--   [[0,1,2],[3,4,5]]
--   
toNestedLists :: forall dims a. IsGrid dims => Grid dims a -> NestedLists dims a -- | The index type for Grids. newtype Coord (dims :: [Nat]) Coord :: [Int] -> Coord [unCoord] :: Coord -> [Int] -- | Safely construct a Coord for a given grid size, checking that -- all indexes are in range -- --
--   λ> coord @[3, 3] [1, 2]
--   Just [1, 2]
--   
--   λ> coord @[3, 3] [3, 3]
--   Nothing
--   
--   λ> coord @[3, 3] [1, 2, 3]
--   Nothing
--   
coord :: forall dims. SingI dims => [Int] -> Maybe (Coord dims) -- | Get the first index from a Coord unconsC :: Coord (n : ns) -> (Int, Coord ns) -- | Append two Coords appendC :: Coord ns -> Coord ms -> Coord (ns ++ ms) -- | If no definition is provided, this will default to gindex. index :: Representable f => f a -> Rep f -> a -- | Update elements of a grid (//) :: forall dims a. IsGrid dims => Grid dims a -> [(Coord dims, a)] -> Grid dims a -- | Focus an element of a Grid given its Coord cell :: forall dims a. IsGrid dims => Coord dims -> Lens' (Grid dims a) a -- | Perform a computation based on the context surrounding a cell Good for -- doing things like Linear Image Filters (e.g. gaussian blur) or -- simulating Cellular Automata (e.g. Conway's game of life) -- -- This function accepts a function which indicates what to do with -- 'out-of-bounds' indexes, clampWindow, wrapWindow and -- safeWindow are examples. -- -- It also acccepts a transformation function which operates over the -- functor created by the first parameter and collapses it down to a new -- value for the cell at that position. -- -- This function is best used with Type Applications to denote the -- desired window size; the Grid passed to the given function contains -- the current cell (in the middle) and all the surrounding cells. -- -- Here's an example of computing the average of all neighboring cells, -- repeating values at the edge of the grid when indexes are out of -- bounds (using clampWindow) -- --
--   gaussian :: (IsGrid dims) => Grid dims Double -> Grid dims Double
--   gaussian = autoConvolute clampBounds avg
--    where
--     avg :: Grid '[3, 3] Double -> Double
--     avg g = sum g / fromIntegral (length g)
--   
autoConvolute :: forall window dims f a b. (IsGrid dims, IsGrid window, Functor f) => (Grid window (Coord dims) -> f (Coord dims)) -> (f a -> b) -> Grid dims a -> Grid dims b -- | This is a fully generic version of autoConvolute which allows -- the user to provide a function which builds a context from the current -- coord, then provides a collapsing function over the same functor. convolute :: forall dims f a b. (Functor f, IsGrid dims) => (Coord dims -> f (Coord dims)) -> (f a -> b) -> Grid dims a -> Grid dims b -- | Given a coordinate generate a grid of size window filled with -- coordinates surrounding the given coord. Mostly used internally window :: forall window dims. IsGrid window => Coord dims -> Grid window (Coord dims) partitionFocus :: forall window a. (Centered window, IsGrid window) => Grid window a -> (a, Grid window (Maybe a)) centerCoord :: Centered dims => Coord dims -- | Use with autoConvolute; Clamp out-of-bounds coordinates to the -- nearest in-bounds coord. clampBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> f (Coord dims) -- | Use with autoConvolute; Wrap out-of-bounds coordinates pac-man -- style to the other side of the grid wrapBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> f (Coord dims) -- | Use with autoConvolute; Out of bounds coords become -- Nothing omitBounds :: (IsGrid dims, Functor f) => f (Coord dims) -> Compose f Maybe (Coord dims) -- | Transpose a 2 dimensional matrix. Equivalent to: -- --
--   permute @[1, 0]
--   
transpose :: (IsGrid '[x, y], IsGrid '[y, x]) => Grid '[x, y] a -> Grid '[y, x] a -- | Permute dimensions of a Grid. This is similar to MatLab's -- permute function -- -- permute requires a type application containing a permutation -- pattern; The pattern is a re-ordering of the list [0..n] -- which represents the new dimension order. For example the permutation -- pattern [1, 2, 0] when applied to the dimensions [4, 5, -- 6] results in the dimensions [5, 6, 4]. -- -- For 2 dimensional matrixes, a permutation using [1, 0] is -- simply a matrix transpose -- --
--   λ> small
--   fromNestedLists
--     [[0,1,2]
--     ,[3,4,5]
--     ,[6,7,8]]
--   
--   λ> permute @[1, 0] small
--   fromNestedLists
--     [[0,3,6]
--     ,[1,4,7]
--     ,[2,5,8]]
--   
permute :: forall (key :: [Nat]) from a invertedKey. (SingI invertedKey, invertedKey ~ InvertKey (EnumFromTo 0 (Length from - 1)) key, ValidPermutation key from, IsGrid from, IsGrid (Permuted key from)) => Grid from a -> Grid (Permuted key from) a -- | Permute the dimensions of a coordinate according to a permutation -- pattern. see permute regarding permutation patterns permuteCoord :: forall (key :: [Nat]) to from. SingI key => Coord from -> Coord to -- | The inverse of splitGrid, joinGrid will nest a grid from: > -- Grid outer (Grid inner a) -> Grid (outer ++ inner) a -- -- For example, you can nest a simple 3x3 from smaller [3] grids as -- follows: -- --
--   joinGrid (myGrid :: Grid [3] (Grid [3] a)) :: Grid '[3, 3] a
--   
joinGrid :: Grid dims (Grid ns a) -> Grid (dims ++ ns) a -- | The inverse of joinGrid, splitGrid outerDims innerDims -- will un-nest a grid from: > Grid (outer ++ inner) a -> Grid -- outer (Grid inner a) -- -- For example, you can unnest a simple 3x3 as follows: -- --
--   splitGrid @'[3] @'[3] myGrid :: Grid '[3] (Grid [3] a)
--   
splitGrid :: forall outer inner a from. (IsGrid from, IsGrid inner, IsGrid outer, NestedLists from a ~ NestedLists outer (NestedLists inner a)) => Grid from a -> Grid outer (Grid inner a) type IsGrid dims = (AllC KnownNat dims, SingI dims, Sizable dims, Representable (Grid dims), Enum (Coord dims), Bounded (Coord dims), Neighboring dims) -- | Represents valid dimensionalities. All non empty lists of Nats have an -- instance class Sizable (dims :: [Nat]) nestLists :: Sizable dims => Proxy dims -> Vector a -> NestedLists dims a unNestLists :: Sizable dims => Proxy dims -> NestedLists dims a -> [a] -- | Get the total size of a Grid of the given dimensions -- --
--   gridSize (Proxy @'[2, 2]) == 4
--   
gridSize :: Sizable dims => Proxy dims -> Int -- | Computes the level of nesting requried to represent a given grid -- dimensionality as a nested list -- --
--   NestedLists [2, 3] Int == [[Int]]
--   NestedLists [2, 3, 4] Int == [[[Int]]]
--   
type family NestedLists (dims :: [Nat]) a class Neighboring dims type ValidPermutation key from = (Sort key == EnumFromTo 0 (Length from - 1)) ?! ( 'Text "Malformed permutation hint: " :<>: 'ShowType key :$$: 'Text "When permuting matrix of size: " :<>: 'ShowType from :$$: 'Text "Key must be a permutation of " :<>: 'ShowType (EnumFromTo 0 (Length from - 1)) :$$: 'Text "e.g. the identity permutation for 2x2 is @[0, 1]" :$$: 'Text "e.g. matrix transpose for 2x2 is @[1, 0]") type family Permuted (key :: [Nat]) (from :: [Nat]) :: [Nat] module Data.Grid.Examples.Intro simpleGrid :: Grid '[5, 5] Int coordGrid :: Grid '[5, 5] (Coord '[5, 5]) avg :: Foldable f => f Int -> Int mx :: Foldable f => f Int -> Int verySmall :: Grid '[2, 2] Int small :: Grid '[3, 3] Int small' :: Grid '[5, 5] Int med :: Grid '[3, 3, 3] Int big :: Grid '[5, 5, 5, 5] Int gauss :: IsGrid dims => Grid dims Double -> Grid dims Double clampGauss :: IsGrid dims => Grid dims Double -> Grid dims Double seeNeighboring :: Grid '[3, 3] a -> Grid '[3, 3] (Grid '[3, 3] (Maybe a)) coords :: Grid '[3, 3] (Coord '[3, 3]) doubleGrid :: Grid '[3, 3] Double simpleGauss :: Grid '[3, 3] Double pacmanGauss :: IsGrid dims => Grid dims Double -> Grid dims Double module Data.Grid.Examples.Conway rule' :: Grid [3, 3] Bool -> Bool step :: IsGrid dims => Grid dims Bool -> Grid dims Bool glider :: [Coord '[10, 10]] start :: Grid '[10, 10] Bool simulate :: Int -> Grid '[10, 10] Bool showBool :: Bool -> Char showGrid :: IsGrid '[x, y] => Grid '[x, y] Bool -> String