[Haskell-cafe] Subject: ANNOUNCE: grid-3.0.1 (tile maps for board games or maths)

Twan van Laarhoven twanvl at gmail.com
Mon Feb 18 14:08:02 CET 2013


On 18/02/13 13:41, Amy de Buitléir wrote:
> I'm happy to announce a new major release of the grid package:
>
>      http://hackage.haskell.org/package/grid
>      https://github.com/mhwombat/grid/wiki (wiki)
>

After taking a peek at the documentation: have you considered removing the size 
function from Grid? It is the only function that actually uses the type 
parameter 's'. If you really need it, I would suggest putting it in a separate 
class,

     class HasSize a s | a -> s where
         size :: a -> s


It might also be useful to add a rectangular grid type where diagonally adjacent 
cells are also neighbors.

Another interesting idea is to have modifier types that change which cells are 
neighbors, for example you could have
     class Colinear g x | g x where
         -- | Are three points separated by moves in the same direction?
         isColinear :: g -> x -> x -> x -> Bool

     -- neighbors are separated by diagonal moves
     newtype Diagonal g = Diagonal g
     instance (Grid g, Colinear g x) => Grid (Diagonal g) x where
         neighbors g x = [z | y <- neigbhors x, z <- neigbhors y
                            , not (isColinear x y z)]

     newtype Rook g = ...
     newtype Knight g = ...
     -- etc.


Twan



More information about the Haskell-Cafe mailing list