+class (Num a, Ord a) => Coord a where
+ (^+^^) :: a -> a -> a
+ neighbourCells :: S.Set a
+instance Coord (V3 Int) where
+ x ^+^^ y = x ^+^ y
+ neighbourCells = S.fromList [ V3 dx dy dz
+ | dx <- [-1, 0, 1]
+ , dy <- [-1, 0, 1]
+ , dz <- [-1, 0, 1]
+ , (dx, dy, dz) /= (0, 0, 0)
+ ]
+instance Coord (V4 Int) where
+ x ^+^^ y = x ^+^ y
+ neighbourCells = S.fromList [ V4 dx dy dz dw
+ | dx <- [-1, 0, 1]
+ , dy <- [-1, 0, 1]
+ , dz <- [-1, 0, 1]
+ , dw <- [-1, 0, 1]
+ , (dx, dy, dz, dw) /= (0, 0, 0, 0)
+ ]
+
+type Grid a = S.Set a