type Position = (Int, Int)
-- the directions. See below for functions for turning
data Direction = North | East | South | West
deriving (Enum, Show, Bounded, Eq)
type Position = (Int, Int)
-- the directions. See below for functions for turning
data Direction = North | East | South | West
deriving (Enum, Show, Bounded, Eq)
execute m (Forward s) = m {position = forward s (direction m) (position m)}
execute m Clockwise = m {direction = turnCW (direction m)}
execute m Anticlockwise = m {direction = turnACW (direction m)}
execute m (Forward s) = m {position = forward s (direction m) (position m)}
execute m Clockwise = m {direction = turnCW (direction m)}
execute m Anticlockwise = m {direction = turnACW (direction m)}
forward s North (e, n) = (e, n+s)
forward s South (e, n) = (e, n-s)
forward s West (e, n) = (e-s, n)
forward s North (e, n) = (e, n+s)
forward s South (e, n) = (e, n-s)
forward s West (e, n) = (e-s, n)
-- instructions is some optional space followed by many instructions
instrsP = optional sc *> many instrP
-- instructions is some optional space followed by many instructions
instrsP = optional sc *> many instrP