grid 4.0 → 4.1
raw patch · 4 files changed
+28/−70 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Math.Geometry.GridMap: adjacentTilesToward :: Grid g => g -> Index g -> Index g -> [Index g]
- Math.Geometry.GridMap: boundary :: BoundedGrid g => g -> [Index g]
- Math.Geometry.GridMap: centre :: BoundedGrid g => g -> [Index g]
- Math.Geometry.GridMap: class Grid g where type family Index g minDistance g xs x = minimum . map (distance g x) $ xs neighbours g x = filter (\ a -> distance g x a ≡ 1) $ indices g numNeighbours g = length . neighbours g contains g x = x `elem` indices g viewpoint g p = map f (indices g) where f x = (x, distance g p x) tileCount = length . indices null g = tileCount g ≡ 0 nonNull = not . null edges g = nubBy sameEdge $ concatMap (`adjacentEdges` g) $ indices g isAdjacent g a b = a `elem` (neighbours g b) adjacentTilesToward g a b = filter f $ neighbours g a where f x = distance g x b ≡ distance g a b - 1 minimalPaths g a b | a ≡ b = [[a]] | distance g a b ≡ 1 = [[a, b]] | otherwise = map (a :) xs where xs = concatMap (\ x -> minimalPaths g x b) ys ys = adjacentTilesToward g a b
- Math.Geometry.GridMap: contains :: (Grid g, Eq (Index g)) => g -> Index g -> Bool
- Math.Geometry.GridMap: distance :: Grid g => g -> Index g -> Index g -> Int
- Math.Geometry.GridMap: edges :: (Grid g, Eq (Index g)) => g -> [(Index g, Index g)]
- Math.Geometry.GridMap: indices :: Grid g => g -> [Index g]
- Math.Geometry.GridMap: isAdjacent :: (Grid g, Eq (Index g)) => g -> Index g -> Index g -> Bool
- Math.Geometry.GridMap: isBoundary :: (BoundedGrid g, Eq (Index g)) => g -> Index g -> Bool
- Math.Geometry.GridMap: isCentre :: (BoundedGrid g, Eq (Index g)) => g -> Index g -> Bool
- Math.Geometry.GridMap: minDistance :: Grid g => g -> [Index g] -> Index g -> Int
- Math.Geometry.GridMap: minimalPaths :: (Grid g, Eq (Index g)) => g -> Index g -> Index g -> [[Index g]]
- Math.Geometry.GridMap: neighbours :: Grid g => g -> Index g -> [Index g]
- Math.Geometry.GridMap: nonNull :: Grid g => g -> Bool
- Math.Geometry.GridMap: null :: Grid g => g -> Bool
- Math.Geometry.GridMap: numNeighbours :: Grid g => g -> Index g -> Int
- Math.Geometry.GridMap: size :: FiniteGrid g => g -> Size g
- Math.Geometry.GridMap: tileCount :: Grid g => g -> Int
- Math.Geometry.GridMap: viewpoint :: Grid g => g -> Index g -> [(Index g, Int)]
Files
- grid.cabal +1/−1
- src/Math/Geometry/Grid.hs +11/−0
- src/Math/Geometry/GridInternal.hs +0/−4
- src/Math/Geometry/GridMap.hs +16/−65
grid.cabal view
@@ -1,5 +1,5 @@ name: grid-version: 4.0+version: 4.1 synopsis: Tools for working with regular grids (graphs, lattices). description: Provides tools for working with regular arrangements of tiles, such as might be used in a board game or some
src/Math/Geometry/Grid.hs view
@@ -30,25 +30,36 @@ FiniteGrid(..), BoundedGrid(..), -- * Grids with triangular tiles+ -- ** Unbounded grid with triangular tiles UnboundedTriGrid,+ -- ** Triangular grid with triangular tiles TriTriGrid, triTriGrid,+ -- ** Parallelogram-shaped grid with triangular tiles ParaTriGrid, paraTriGrid,+ -- ** Rectangular grid with triangular tiles RectTriGrid, rectTriGrid,+ -- ** Toroidal grid with triangular tiles TorTriGrid, torTriGrid, -- * Grids with square tiles+ -- ** Unbounded grid with square tiles UnboundedSquareGrid,+ -- ** Rectangular grid with square tiles RectSquareGrid, rectSquareGrid,+ -- ** Toroidal grid with square tiles TorSquareGrid, torSquareGrid, -- * Grids with hexagonal tiles+ -- ** Unbounded grid with hexagonal tiles UnboundedHexGrid,+ -- ** Hexagonal grid with hexagonal tiles HexHexGrid, hexHexGrid,+ -- ** Parallelogram-shaped grid with hexagonal tiles ParaHexGrid, paraHexGrid -- * Example
src/Math/Geometry/GridInternal.hs view
@@ -15,12 +15,10 @@ module Math.Geometry.GridInternal (- -- * Generic Grid(..), FiniteGrid(..), BoundedGrid(..), WrappedGrid(..),- -- * Grids with triangular tiles UnboundedTriGrid, TriTriGrid, triTriGrid,@@ -30,13 +28,11 @@ rectTriGrid, TorTriGrid, torTriGrid,- -- * Grids with square tiles UnboundedSquareGrid, RectSquareGrid, rectSquareGrid, TorSquareGrid, torSquareGrid,- -- * Grids with hexagonal tiles UnboundedHexGrid, HexHexGrid, hexHexGrid,
src/Math/Geometry/GridMap.hs view
@@ -18,67 +18,17 @@ module Math.Geometry.GridMap (- -- * Differences between @GridMap@ and @Map@.- -- $Compare- -- * Map classes and types- GridMap,- BaseGrid,- G.Index,- G.Grid,-- -- * Deconstruction- toMap,- toGrid,- toList,-- -- * Grid functions- G.indices,- G.distance,- G.minDistance,- G.neighbours,- G.numNeighbours,- G.contains,- G.viewpoint,- G.tileCount,- G.null,- G.nonNull,- G.edges,- G.isAdjacent,- G.adjacentTilesToward,- G.minimalPaths,- G.size,- G.boundary,- G.isBoundary,- G.centre,- G.isCentre, -- -- * Map functions- -- ** Operators- (!),-- -- ** Query- lookup,- findWithDefault,-- -- ** Update- adjust,- adjustWithKey,-- -- ** Traversal- map,- mapWithKey,+ GridMap(..), - -- ** Folds--- fold,--- foldMap,+ -- * Folds M.foldr, M.foldr', M.foldl, M.foldl', - -- ** Conversion- elems+ -- * Differences between @GridMap@ and @Map@.+ -- $Compare ) where import Prelude hiding (lookup, map, foldr, foldl, foldr1, foldl1, null)@@ -167,8 +117,8 @@ Map function | corresponding GridMap function --------------------+---------------------------------------------- ! | !-\\ | See note 1-empty | 'lazyGridMap' g []+\\\\ | See note 1+empty | 'Math.Geometry.GridMap.Lazy.lazyGridMap' g [] findWithDefault | 'findWithDefault' insert | See notes 1, 2 lookup | 'lookup'@@ -176,11 +126,11 @@ lookupLT | See notes 1, 3 lookupGE | See notes 1, 3 lookupGT | See notes 1, 3-member | 'inGrid'-notMember | not 'inGrid'-null | 'null'+member | 'Math.Geometry.Grid.contains'+notMember | not 'Math.Geometry.Grid.contains'+null | 'Math.Geometry.Grid.null' singleton | 'lazyGridMap' g [v]-size | 'size', 'tileCount'*+size | 'Math.Geometry.Grid.size', 'Math.Geometry.Grid.tileCount' insert | See notes 1, 2 insertWith | See notes 1, 2 insertWithKey | See notes 1, 2@@ -204,7 +154,7 @@ intersectionWith | See notes 1, 2 intersectionWithKey | See notes 1, 2 mergeWithKey | See notes 1, 2-M.map | fmap, or see note 1+M.map | 'Math.Geometry.GridMap.Lazy.fmap', or see note 1 mapWithKey | See note 1 traverseWithKey | See notes 1, 2 mapAccum | See note 1@@ -225,11 +175,11 @@ keys | 'indices' assocs | See note 1 keysSet | See note 1-fromSet | 'lazyGridMap' (constructor)+fromSet | 'Math.Geometry.GridMap.Lazy.lazyGridMap' toList | See note 1-fromList | 'lazyGridMap' (constructor)-fromListWithKey | 'lazyGridMap' (constructor)-fromListWith | 'lazyGridMap' (constructor)+fromList | 'Math.Geometry.GridMap.Lazy.lazyGridMap'+fromListWithKey | 'Math.Geometry.GridMap.Lazy.lazyGridMap'+fromListWith | 'Math.Geometry.GridMap.Lazy.lazyGridMap' toAscList | See notes 1, 3 toDescList | See notes 1, 3 fromAscList | See notes 1, 3@@ -275,6 +225,7 @@ @ Notes:+ 1. You can extract the map using @'toMap'@ and apply the function from @Data.Map@ to the result.