never executed always true always false
1 module HelVM.HelMA.Automata.Piet.Types.DirectionPointer
2 ( DirectionPointer (..)
3 , addCoordinates
4 , move
5 , nextPointer
6 , rotate
7 ) where
8
9 import HelVM.HelMA.Automata.Piet.Types.Coordinates
10 import HelVM.HelMA.Automata.Piet.Types.Extra
11
12 import Lens.Micro
13
14 addCoordinates ∷ DirectionPointer → Coordinates → Coordinates
15 addCoordinates DPRight (x, y) = (x + 1, y)
16 addCoordinates DPDown (x, y) = (x, y + 1)
17 addCoordinates DPLeft (x, y) = (x - 1, y)
18 addCoordinates DPUp (x, y) = (x, y - 1)
19
20 move ∷ DirectionPointer → Coordinates → Coordinates
21 move DPLeft = _1 -~ 1
22 move DPRight = _1 +~ 1
23 move DPUp = _2 -~ 1
24 move DPDown = _2 +~ 1
25
26 nextPointer ∷ DirectionPointer → DirectionPointer
27 nextPointer DPLeft = DPUp
28 nextPointer DPUp = DPRight
29 nextPointer DPRight = DPDown
30 nextPointer DPDown = DPLeft
31
32 rotate ∷ Int → DirectionPointer → DirectionPointer
33 rotate = change 4
34
35 data DirectionPointer
36 = DPRight
37 | DPDown
38 | DPLeft
39 | DPUp
40 deriving stock (Bounded, Enum, Eq, Ord, Read, Show)