grid 7.8.6 → 7.8.7
raw patch · 6 files changed
+133/−137 lines, 6 filesdep ~QuickCheckdep ~basedep ~containersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: QuickCheck, base, containers
API changes (from Hackage documentation)
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_0HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_0HexHexGrid
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_0ParaHexGrid
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_0UnboundedHexGrid
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_1HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_2HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_3HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_4HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal.C1_5HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal.D1HexDirection
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal.D1HexHexGrid
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal.D1ParaHexGrid
- Math.Geometry.Grid.HexagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal.D1UnboundedHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_0HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_0HexHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_0RectHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_0UnboundedHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_1HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_2HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_3HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_4HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Constructor Math.Geometry.Grid.HexagonalInternal2.C1_5HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal2.D1HexDirection
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal2.D1HexHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal2.D1RectHexGrid
- Math.Geometry.Grid.HexagonalInternal2: instance GHC.Generics.Datatype Math.Geometry.Grid.HexagonalInternal2.D1UnboundedHexGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_0OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_0RectOctGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_0TorOctGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_0UnboundedOctGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_1OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_2OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_3OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_4OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_5OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_6OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.OctagonalInternal.C1_7OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.OctagonalInternal.D1OctDirection
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.OctagonalInternal.D1RectOctGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.OctagonalInternal.D1TorOctGrid
- Math.Geometry.Grid.OctagonalInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.OctagonalInternal.D1UnboundedOctGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.SquareInternal.C1_0RectSquareGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.SquareInternal.C1_0TorSquareGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.SquareInternal.C1_0UnboundedSquareGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.SquareInternal.D1RectSquareGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.SquareInternal.D1TorSquareGrid
- Math.Geometry.Grid.SquareInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.SquareInternal.D1UnboundedSquareGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0ParaTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0RectTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0TorTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0TriTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0UnboundedTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0XCylTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_0YCylTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_1TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_2TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_3TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_4TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Constructor Math.Geometry.Grid.TriangularInternal.C1_5TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1ParaTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1RectTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1TorTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1TriDirection
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1TriTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1UnboundedTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1XCylTriGrid
- Math.Geometry.Grid.TriangularInternal: instance GHC.Generics.Datatype Math.Geometry.Grid.TriangularInternal.D1YCylTriGrid
- Math.Geometry.GridMap.Lazy: instance GHC.Generics.Constructor Math.Geometry.GridMap.Lazy.C1_0LGridMap
- Math.Geometry.GridMap.Lazy: instance GHC.Generics.Datatype Math.Geometry.GridMap.Lazy.D1LGridMap
- Math.Geometry.GridMap.Lazy: instance GHC.Generics.Selector Math.Geometry.GridMap.Lazy.S1_0_0LGridMap
- Math.Geometry.GridMap.Lazy: instance GHC.Generics.Selector Math.Geometry.GridMap.Lazy.S1_0_1LGridMap
+ Math.Geometry.Grid: type family Size g;
+ Math.Geometry.Grid: }
+ Math.Geometry.GridInternal: type family Size g;
+ Math.Geometry.GridInternal: }
+ Math.Geometry.GridMap: type family BaseGrid gm v;
+ Math.Geometry.GridMap: }
- Math.Geometry.Grid: class Grid g => FiniteGrid g where type family Size g
+ Math.Geometry.Grid: class Grid g => FiniteGrid g where type Size g where {
- Math.Geometry.Grid: class Grid g where type family Index g type family Direction g minDistance = defaultMinDistance neighbours = defaultNeighbours neighboursOfSet = defaultNeighboursOfSet neighbour = defaultNeighbour numNeighbours g = length . neighbours g contains g a = a `elem` indices g tileCount = length . indices null g = tileCount g == 0 nonNull = not . null edges = defaultEdges viewpoint g p = map f (indices g) where f a = (a, distance g p a) isAdjacent = defaultIsAdjacent adjacentTilesToward = defaultAdjacentTilesToward minimalPaths = defaultMinimalPaths defaultMinDistance g xs a = minimum . map (distance g a) $ xs defaultNeighbours g a = filter (\ b -> distance g a b == 1) $ indices g defaultNeighboursOfSet g as = ns \\ as where ns = nub . concatMap (neighbours g) $ as defaultNeighbour g a d = maybeHead . filter (\ b -> [d] == directionTo g a b) . neighbours g $ a where maybeHead (x : _) = Just x maybeHead _ = Nothing defaultTileCount = length . indices defaultEdges g = nubBy sameEdge $ concatMap (`adjacentEdges` g) $ indices g defaultIsAdjacent g a b = distance g a b == 1 defaultAdjacentTilesToward g a b = filter f $ neighbours g a where f c = distance g c b == distance g a b - 1 defaultMinimalPaths g a b | a == b = [[a]] | distance g a b == 1 = [[a, b]] | otherwise = map (a :) xs where xs = concatMap (\ c -> minimalPaths g c b) ys ys = adjacentTilesToward g a b
+ Math.Geometry.Grid: class Grid g where type Index g type Direction g minDistance = defaultMinDistance neighbours = defaultNeighbours neighboursOfSet = defaultNeighboursOfSet neighbour = defaultNeighbour numNeighbours g = length . neighbours g contains g a = a `elem` indices g tileCount = length . indices null g = tileCount g == 0 nonNull = not . null edges = defaultEdges viewpoint g p = map f (indices g) where f a = (a, distance g p a) isAdjacent = defaultIsAdjacent adjacentTilesToward = defaultAdjacentTilesToward minimalPaths = defaultMinimalPaths defaultMinDistance g xs a = minimum . map (distance g a) $ xs defaultNeighbours g a = filter (\ b -> distance g a b == 1) $ indices g defaultNeighboursOfSet g as = ns \\ as where ns = nub . concatMap (neighbours g) $ as defaultNeighbour g a d = maybeHead . filter (\ b -> [d] == directionTo g a b) . neighbours g $ a where maybeHead (x : _) = Just x maybeHead _ = Nothing defaultTileCount = length . indices defaultEdges g = nubBy sameEdge $ concatMap (`adjacentEdges` g) $ indices g defaultIsAdjacent g a b = distance g a b == 1 defaultAdjacentTilesToward g a b = filter f $ neighbours g a where f c = distance g c b == distance g a b - 1 defaultMinimalPaths g a b | a == b = [[a]] | distance g a b == 1 = [[a, b]] | otherwise = map (a :) xs where xs = concatMap (\ c -> minimalPaths g c b) ys ys = adjacentTilesToward g a b where {
- Math.Geometry.GridInternal: class Grid g => FiniteGrid g where type family Size g
+ Math.Geometry.GridInternal: class Grid g => FiniteGrid g where type Size g where {
- Math.Geometry.GridInternal: class Grid g where type family Index g type family Direction g minDistance = defaultMinDistance neighbours = defaultNeighbours neighboursOfSet = defaultNeighboursOfSet neighbour = defaultNeighbour numNeighbours g = length . neighbours g contains g a = a `elem` indices g tileCount = length . indices null g = tileCount g == 0 nonNull = not . null edges = defaultEdges viewpoint g p = map f (indices g) where f a = (a, distance g p a) isAdjacent = defaultIsAdjacent adjacentTilesToward = defaultAdjacentTilesToward minimalPaths = defaultMinimalPaths defaultMinDistance g xs a = minimum . map (distance g a) $ xs defaultNeighbours g a = filter (\ b -> distance g a b == 1) $ indices g defaultNeighboursOfSet g as = ns \\ as where ns = nub . concatMap (neighbours g) $ as defaultNeighbour g a d = maybeHead . filter (\ b -> [d] == directionTo g a b) . neighbours g $ a where maybeHead (x : _) = Just x maybeHead _ = Nothing defaultTileCount = length . indices defaultEdges g = nubBy sameEdge $ concatMap (`adjacentEdges` g) $ indices g defaultIsAdjacent g a b = distance g a b == 1 defaultAdjacentTilesToward g a b = filter f $ neighbours g a where f c = distance g c b == distance g a b - 1 defaultMinimalPaths g a b | a == b = [[a]] | distance g a b == 1 = [[a, b]] | otherwise = map (a :) xs where xs = concatMap (\ c -> minimalPaths g c b) ys ys = adjacentTilesToward g a b
+ Math.Geometry.GridInternal: class Grid g where type Index g type Direction g minDistance = defaultMinDistance neighbours = defaultNeighbours neighboursOfSet = defaultNeighboursOfSet neighbour = defaultNeighbour numNeighbours g = length . neighbours g contains g a = a `elem` indices g tileCount = length . indices null g = tileCount g == 0 nonNull = not . null edges = defaultEdges viewpoint g p = map f (indices g) where f a = (a, distance g p a) isAdjacent = defaultIsAdjacent adjacentTilesToward = defaultAdjacentTilesToward minimalPaths = defaultMinimalPaths defaultMinDistance g xs a = minimum . map (distance g a) $ xs defaultNeighbours g a = filter (\ b -> distance g a b == 1) $ indices g defaultNeighboursOfSet g as = ns \\ as where ns = nub . concatMap (neighbours g) $ as defaultNeighbour g a d = maybeHead . filter (\ b -> [d] == directionTo g a b) . neighbours g $ a where maybeHead (x : _) = Just x maybeHead _ = Nothing defaultTileCount = length . indices defaultEdges g = nubBy sameEdge $ concatMap (`adjacentEdges` g) $ indices g defaultIsAdjacent g a b = distance g a b == 1 defaultAdjacentTilesToward g a b = filter f $ neighbours g a where f c = distance g c b == distance g a b - 1 defaultMinimalPaths g a b | a == b = [[a]] | distance g a b == 1 = [[a, b]] | otherwise = map (a :) xs where xs = concatMap (\ c -> minimalPaths g c b) ys ys = adjacentTilesToward g a b where {
- Math.Geometry.GridMap: class (Grid (BaseGrid gm v), Foldable gm) => GridMap (gm :: * -> *) v where type family BaseGrid gm v (!) gm k = toMap gm ! k toList = toList . toMap lookup k = lookup k . toMap insert = insertWith const insertWith f = insertWithKey (\ _ x' y' -> f x' y') insertLookupWithKey f k v gm = (lookup k gm, insertWithKey f k v gm) adjust f = adjustWithKey (\ _ v -> f v) findWithDefault v k = findWithDefault v k . toMap keys = keys . toMap elems = elems . toMap map f = mapWithKey (\ _ v -> f v) filter p = filterWithKey (\ _ x -> p x)
+ Math.Geometry.GridMap: class (Grid (BaseGrid gm v), Foldable gm) => GridMap (gm :: * -> *) v where type BaseGrid gm v (!) gm k = toMap gm ! k toList = toList . toMap lookup k = lookup k . toMap insert = insertWith const insertWith f = insertWithKey (\ _ x' y' -> f x' y') insertLookupWithKey f k v gm = (lookup k gm, insertWithKey f k v gm) adjust f = adjustWithKey (\ _ v -> f v) findWithDefault v k = findWithDefault v k . toMap keys = keys . toMap elems = elems . toMap map f = mapWithKey (\ _ v -> f v) filter p = filterWithKey (\ _ x -> p x) where {
- Math.Geometry.GridMap.Lazy: empty :: Grid g => g -> LGridMap g v
+ Math.Geometry.GridMap.Lazy: empty :: g -> LGridMap g v
Files
- LICENSE +22/−19
- grid.cabal +64/−68
- src/Math/Geometry/GridMap/Lazy.hs +1/−1
- test/Main.hs +0/−36
- test/Math/Geometry/GridQC.hs +10/−13
- test/TestMain.hs +36/−0
LICENSE view
@@ -1,27 +1,30 @@-Copyright (c) Amy de Buitléir 2010-2015+Copyright Amy de Buitléir (c) 2016+ All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met:+Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer.-* Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in the- documentation and/or other materials provided with the distribution.-* Neither the name of the author nor the names of other contributors- may be used to endorse or promote products derived from this software- without specific prior written permission.+ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Amy de Buitléir nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
grid.cabal view
@@ -1,71 +1,67 @@-Name: grid-Version: 7.8.6-Stability: experimental-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- other type of grid map. Currently supports triangular,- square, and hexagonal tiles, with various 2D and- toroidal layouts.- The userguide is available at- <https://github.com/mhwombat/grid/wiki>.-Category: Math-License: BSD3-License-file: LICENSE-Copyright: (c) Amy de Buitléir 2010-2016-Homepage: https://github.com/mhwombat/grid-Bug-reports: https://github.com/mhwombat/grid/issues-Author: Amy de Buitléir-Maintainer: amy@nualeargais.ie-Build-Type: Simple-Cabal-Version: >=1.8--source-repository head- type: git- location: https://github.com/mhwombat/grid.git--source-repository this- type: git- location: https://github.com/mhwombat/grid.git- tag: 7.8.5-+name: grid+version: 7.8.7+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+ other type of grid map. Currently supports triangular,+ square, and hexagonal tiles, with various 2D and+ toroidal layouts.+ The userguide is available at+ <https://github.com/mhwombat/grid/wiki>.+homepage: https://github.com/mhwombat/grid#readme+bug-reports: https://github.com/mhwombat/grid/issues+license: BSD3+license-file: LICENSE+author: Amy de Buitléir+maintainer: amy@nualeargais.ie+copyright: (c) Amy de Buitléir 2010-2016+category: Math+build-type: Simple+-- extra-source-files:+cabal-version: >=1.10 library- hs-source-dirs: src- build-depends: base ==4.*,- cereal >=0.4 && < 0.6,- containers ==0.5.*- ghc-options: -Wall- exposed-modules: Math.Geometry.Grid,- Math.Geometry.Grid.Triangular,- Math.Geometry.Grid.Square,- Math.Geometry.Grid.Hexagonal,- Math.Geometry.Grid.Hexagonal2,- Math.Geometry.Grid.Octagonal,- Math.Geometry.GridInternal,- Math.Geometry.Grid.TriangularInternal,- Math.Geometry.Grid.SquareInternal,- Math.Geometry.Grid.HexagonalInternal,- Math.Geometry.Grid.HexagonalInternal2,- Math.Geometry.Grid.OctagonalInternal,- Math.Geometry.GridMap,- Math.Geometry.GridMap.Lazy+ hs-source-dirs: src+ exposed-modules: Math.Geometry.Grid,+ Math.Geometry.Grid.Triangular,+ Math.Geometry.Grid.Square,+ Math.Geometry.Grid.Hexagonal,+ Math.Geometry.Grid.Hexagonal2,+ Math.Geometry.Grid.Octagonal,+ Math.Geometry.GridInternal,+ Math.Geometry.Grid.TriangularInternal,+ Math.Geometry.Grid.SquareInternal,+ Math.Geometry.Grid.HexagonalInternal,+ Math.Geometry.Grid.HexagonalInternal2,+ Math.Geometry.Grid.OctagonalInternal,+ Math.Geometry.GridMap,+ Math.Geometry.GridMap.Lazy+ ghc-options: -Wall+ build-depends: base >= 4.7 && < 5,+ cereal >=0.4 && <0.6,+ containers ==0.5.*+ default-language: Haskell2010 -test-suite grid-tests- type: exitcode-stdio-1.0- build-depends: base ==4.*,- containers ==0.5.*,- test-framework-quickcheck2 ==0.3.*,- QuickCheck ==2.8.*,- test-framework ==0.8.*,- grid- hs-source-dirs: test- ghc-options: -Wall- main-is: Main.hs- other-modules: Math.Geometry.GridQC,- Math.Geometry.Grid.Hexagonal2QC,- Math.Geometry.Grid.HexagonalQC,- Math.Geometry.Grid.OctagonalQC,- Math.Geometry.Grid.SquareQC,- Math.Geometry.Grid.TriangularQC- Math.Geometry.GridMap.LazyQC+test-suite grid-test+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: TestMain.hs+ other-modules: Math.Geometry.GridQC,+ Math.Geometry.Grid.Hexagonal2QC,+ Math.Geometry.Grid.HexagonalQC,+ Math.Geometry.Grid.OctagonalQC,+ Math.Geometry.Grid.SquareQC,+ Math.Geometry.Grid.TriangularQC+ Math.Geometry.GridMap.LazyQC+ build-depends: base,+ grid,+ containers,+ test-framework ==0.8.*,+ test-framework-quickcheck2 ==0.3.*,+ QuickCheck >=2.8 && <2.10+ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+ default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/mhwombat/grid
src/Math/Geometry/GridMap/Lazy.hs view
@@ -52,7 +52,7 @@ where kvs' = Prelude.filter (validIndex . fst) kvs validIndex k = g `G.contains` k -empty :: G.Grid g => g -> LGridMap g v+empty :: g -> LGridMap g v empty g = LGridMap g M.empty instance (G.Grid g, Ord (G.Index g)) => Functor (LGridMap g) where
− test/Main.hs
@@ -1,36 +0,0 @@---------------------------------------------------------------------------- |--- Module : Math.Geometry.Grid.Main--- Copyright : (c) Amy de Buitléir 2012-2016--- License : BSD-style--- Maintainer : amy@nualeargais.ie--- Stability : experimental--- Portability : portable------ QuickCheck tests.-----------------------------------------------------------------------------module Main where--import Math.Geometry.Grid.TriangularQC ( test )-import Math.Geometry.Grid.SquareQC ( test )-import Math.Geometry.Grid.HexagonalQC ( test )-import Math.Geometry.Grid.Hexagonal2QC ( test )-import Math.Geometry.Grid.OctagonalQC ( test )-import Math.Geometry.GridMap.LazyQC (test)--import Test.Framework ( defaultMain, Test )--tests :: [Test]-tests = - [ - Math.Geometry.Grid.TriangularQC.test,- Math.Geometry.Grid.SquareQC.test,- Math.Geometry.Grid.HexagonalQC.test,- Math.Geometry.Grid.Hexagonal2QC.test,- Math.Geometry.Grid.OctagonalQC.test,- Math.Geometry.GridMap.LazyQC.test- ]--main :: IO ()-main = defaultMain tests
test/Math/Geometry/GridQC.hs view
@@ -215,10 +215,9 @@ (a:bs) = points t gridProperties - :: (TestData t, Grid (BaseGrid t), Arbitrary t, - Eq (Index (BaseGrid t)), Ord (Index (BaseGrid t)), - Eq (Direction (BaseGrid t))) - => String -> [(String, t -> Property)]+ :: (TestData t, Grid (BaseGrid t), Eq (Index (BaseGrid t)),+ Ord (Index (BaseGrid t)), Eq (Direction (BaseGrid t))) + => String -> [(String, t -> Property)] gridProperties s = [ ("prop_indices_are_contained: " ++ s, prop_indices_are_contained),@@ -246,7 +245,7 @@ maxDistance :: t -> Int prop_tile_count_correct- :: (TestData t, TestDataF t, Grid (BaseGrid t), Ord (Index (BaseGrid t)))+ :: (TestData t, TestDataF t, Grid (BaseGrid t)) => t -> Property prop_tile_count_correct t = nonNull g ==> tileCount g == expectedTileCount t @@ -259,7 +258,7 @@ where g = grid t prop_distance_in_bounds- :: (TestData t, TestDataF t, Grid (BaseGrid t), Ord (Index (BaseGrid t)))+ :: (TestData t, TestDataF t, Grid (BaseGrid t)) => t -> Property prop_distance_in_bounds t = nonNull g ==> 0 <= n && n <= maxDistance t@@ -316,7 +315,7 @@ (a:b:_) = points t prop_distance_le_maxPossibleDistance- :: (TestData t, TestDataF t, FiniteGrid (BaseGrid t), Ord (Index (BaseGrid t)))+ :: (TestData t, FiniteGrid (BaseGrid t)) => t -> Property prop_distance_le_maxPossibleDistance t = nonNull g ==> distance g a b <= maxPossibleDistance g@@ -335,7 +334,7 @@ dMax = maxPossibleDistance g finiteGridProperties - :: (TestData t, TestDataF t, FiniteGrid (BaseGrid t), Arbitrary t, + :: (TestData t, TestDataF t, FiniteGrid (BaseGrid t), Eq (Index (BaseGrid t)), Ord (Index (BaseGrid t))) => String -> [(String, t -> Property)] finiteGridProperties s = @@ -431,7 +430,7 @@ d = direction t prop_custom_isAdjacent_eq_default- :: (TestData t, Grid (BaseGrid t), Ord (Index (BaseGrid t)))+ :: (TestData t, Grid (BaseGrid t)) => t -> Property prop_custom_isAdjacent_eq_default t = nonNull g ==> isAdjacent g a b == defaultIsAdjacent g a b@@ -439,7 +438,7 @@ (a:b:_) = points t boundedGridProperties - :: (TestData t, TestDataB t, BoundedGrid (BaseGrid t), Arbitrary t, + :: (TestData t, TestDataB t, BoundedGrid (BaseGrid t), Eq (Index (BaseGrid t)), Ord (Index (BaseGrid t)), Eq (Direction (BaseGrid t))) => String -> [(String, t -> Property)]@@ -491,9 +490,7 @@ bs = boundary g boundedGridProperties2- :: (TestData t, TestDataB t, BoundedGrid (BaseGrid t), Arbitrary t, - Eq (Index (BaseGrid t)), Ord (Index (BaseGrid t)),- Eq (Direction (BaseGrid t))) + :: (TestData t, BoundedGrid (BaseGrid t), Ord (Index (BaseGrid t))) => String -> [(String, t -> Property)] boundedGridProperties2 s = [
+ test/TestMain.hs view
@@ -0,0 +1,36 @@+------------------------------------------------------------------------+-- |+-- Module : Math.Geometry.Grid.Main+-- Copyright : (c) Amy de Buitléir 2012-2016+-- License : BSD-style+-- Maintainer : amy@nualeargais.ie+-- Stability : experimental+-- Portability : portable+--+-- QuickCheck tests.+--+------------------------------------------------------------------------+module Main where++import Math.Geometry.Grid.TriangularQC ( test )+import Math.Geometry.Grid.SquareQC ( test )+import Math.Geometry.Grid.HexagonalQC ( test )+import Math.Geometry.Grid.Hexagonal2QC ( test )+import Math.Geometry.Grid.OctagonalQC ( test )+import Math.Geometry.GridMap.LazyQC (test)++import Test.Framework ( defaultMain, Test )++tests :: [Test]+tests = + [ + Math.Geometry.Grid.TriangularQC.test,+ Math.Geometry.Grid.SquareQC.test,+ Math.Geometry.Grid.HexagonalQC.test,+ Math.Geometry.Grid.Hexagonal2QC.test,+ Math.Geometry.Grid.OctagonalQC.test,+ Math.Geometry.GridMap.LazyQC.test+ ]++main :: IO ()+main = defaultMain tests