Safe Haskell | None |
---|---|

Language | Haskell98 |

Grid shapes.

- class Show (Cell a) => GridShape a where
- data Square = Square !Int !Int
- squareNeighbours :: [(Int, Int)] -> Square -> Cell Square -> [Cell Square]
- data Dir
- data Edge = E (Cell Square) Dir
- type Coord = Cell Square
- type Size = GridSize Square
- data Dir'
- data Edge' a = E' a Dir'
- orientedEdge :: Cell Square -> Cell Square -> Edge' (Vertex Square)
- edges :: Foldable f => f (Cell Square) -> (Cell Square -> Bool) -> ([Edge' (Vertex Square)], [Edge' (Vertex Square)])

# Documentation

class Show (Cell a) => GridShape a where Source

The geometry of a grid.

A standard square grid, with cells and vertices indexed by pairs of integers in mathematical coordinates. The bottom-left corner is vertex (0, 0), the bottom-left cell is cell (0, 0).

An edge in a square grid, going up or right from the given cell centre.

An oriented edge in a square grid.
`a`

should be `Cell Square`

or `Vertex Square`

.

orientedEdge :: Cell Square -> Cell Square -> Edge' (Vertex Square) Source

The edge between two neighbouring cells, with the first cell on the left.

edges :: Foldable f => f (Cell Square) -> (Cell Square -> Bool) -> ([Edge' (Vertex Square)], [Edge' (Vertex Square)]) Source

`edges`

computes the outer and inner edges of a set of cells.
The set is given via fold and membership predicate, the result
is a pair `(outer, inner)`

of lists of edges, where the outer
edges are oriented such that the outside is to the left.