puzzle-draw-0.1.0.4: Creating graphics for pencil puzzles.

Safe HaskellNone
LanguageHaskell98

Data.Puzzles.GridShape

Description

Grid shapes.

Synopsis

Documentation

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

The geometry of a grid.

Associated Types

type GridSize a :: * Source

type Cell a :: * Source

type Vertex a :: * Source

Methods

size :: a -> GridSize a Source

cells :: a -> [Cell a] Source

vertices :: a -> [Vertex a] Source

vertexNeighbours :: a -> Cell a -> [Cell a] Source

edgeNeighbours :: a -> Cell a -> [Cell a] Source

Instances

data Square Source

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).

Constructors

Square !Int !Int 

Instances

data Dir Source

Edge direction in a square grid, vertical or horizontal.

Constructors

V 
H 

Instances

data Edge Source

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

Constructors

E (Cell Square) Dir 

Instances

data Dir' Source

Oriented edge direction in a square grid.

Constructors

U 
D 
L 
R 

Instances

data Edge' a Source

An oriented edge in a square grid. a should be Cell Square or Vertex Square.

Constructors

E' a Dir' 

Instances

Eq a => Eq (Edge' a) 
Ord a => Ord (Edge' a) 
Show a => Show (Edge' a) 

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.