{-# LANGUAGE TemplateHaskell #-}
module Data.Geometry.Directions( CardinalDirection(..)
, _North, _East, _South, _West
, oppositeDirection
, InterCardinalDirection(..)
, _NorthWest, _NorthEast, _SouthEast, _SouthWest
, interCardinalsOf
) where
import Control.Lens (makePrisms)
import Data.Util
import GHC.Generics (Generic)
data CardinalDirection = North | East | South | West deriving (Show,Read,Eq,Ord,Enum,Bounded)
makePrisms ''CardinalDirection
oppositeDirection :: CardinalDirection -> CardinalDirection
oppositeDirection = \case
North -> South
East -> West
South -> North
West -> East
data InterCardinalDirection = NorthWest | NorthEast | SouthEast | SouthWest
deriving (Show,Read,Eq,Ord,Enum,Generic)
makePrisms ''InterCardinalDirection
interCardinalsOf :: CardinalDirection -> Two InterCardinalDirection
interCardinalsOf = \case
North -> Two NorthWest NorthEast
East -> Two NorthEast SouthEast
South -> Two SouthEast SouthWest
West -> Two SouthWest NorthWest