Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Describes a direction in two parts; the sense of change in the x coordinate & the sense of change in the y coordinate.
- The IO-format uses a more concise & familiar format based on 8 points of the compass.
- CAVEAT: this separation of direction into orthogonal components is driven by the typical use-case, but requires that one guards against accidental construction of a degenerate 9th direction which defines neither a change in the x coordinate nor the y coordinate.
Synopsis
- type NDirections = Int
- type ByDirection = Array Direction
- data Direction
- nw :: Direction
- n :: Direction
- ne :: Direction
- w :: Direction
- e :: Direction
- sw :: Direction
- s :: Direction
- se :: Direction
- tag :: String
- nDistinctDirections :: NDirections
- parallels :: [Direction]
- diagonals :: [Direction]
- range :: [Direction]
- opposites :: [(Direction, Direction)]
- advanceDirection :: LogicalColour -> Ordering
- attackDirectionsForPawn :: LogicalColour -> [Direction]
- listArrayByDirection :: IArray a e => [e] -> a Direction e
- mkDirection :: Ordering -> Ordering -> Direction
- areAligned :: Direction -> Direction -> Bool
Types
Type-synonyms
type NDirections = Int Source #
A number of directions.
type ByDirection = Array Direction Source #
A boxed array indexed by direction, of arbitrary elements.
Data-types
Define a direction by the sense of change to x & y coordinates.
Instances
Constants
nDistinctDirections :: NDirections Source #
The constant number of distinct directions.
opposites :: [(Direction, Direction)] Source #
- Returns a list of directions, each paired with its anti-parallel.
- CAVEAT: each direction only appears once in the list, on an arbitrary side of a pair.
Functions
advanceDirection :: LogicalColour -> Ordering Source #
The y-direction in which a Pawn
of the specified logical colour advances.
attackDirectionsForPawn :: LogicalColour -> [Direction] Source #
The directions in which a Pawn
can attack.
listArrayByDirection :: IArray a e => [e] -> a Direction e Source #
Array-constructor.
Constructor
:: Ordering | The sense of the change in the x-coordinate. |
-> Ordering | The sense of the change in the y-coordinate. |
-> Direction |
Smart-constructor.