module Route(compTurnRight, compTurnLeft, compPath) where
import Direction
import Message(Message(..))
import Path({-Path(..),-}path, turn)

compPath :: (Path, b)
-> p
-> (Either (Message (Path, b) b) (Message (Path, b) b) -> p)
-> p
compPath (Path
tag, b
ev) p
wrongaddr Either (Message (Path, b) b) (Message (Path, b) b) -> p
c =
    case Path -> (Direction, Path)
path Path
tag of
      (Direction
L, Path
tag') -> Either (Message (Path, b) b) (Message (Path, b) b) -> p
c (Either (Message (Path, b) b) (Message (Path, b) b) -> p)
-> Either (Message (Path, b) b) (Message (Path, b) b) -> p
forall a b. (a -> b) -> a -> b
$ Message (Path, b) b
-> Either (Message (Path, b) b) (Message (Path, b) b)
forall a b. a -> Either a b
Left ((Path, b) -> Message (Path, b) b
forall a b. a -> Message a b
Low (Path
tag', b
ev))
      (Direction
R, Path
tag') -> Either (Message (Path, b) b) (Message (Path, b) b) -> p
c (Either (Message (Path, b) b) (Message (Path, b) b) -> p)
-> Either (Message (Path, b) b) (Message (Path, b) b) -> p
forall a b. (a -> b) -> a -> b
$ Message (Path, b) b
-> Either (Message (Path, b) b) (Message (Path, b) b)
forall a b. b -> Either a b
Right ((Path, b) -> Message (Path, b) b
forall a b. a -> Message a b
Low (Path
tag', b
ev))
      (Direction, Path)
_ -> p
wrongaddr

compTurnLeft :: (Path, b) -> Message (Path, b) b
compTurnLeft  (Path
tag, b
cmd) = (Path, b) -> Message (Path, b) b
forall a b. a -> Message a b
Low (Direction -> Path -> Path
turn Direction
L Path
tag, b
cmd)
compTurnRight :: (Path, b) -> Message (Path, b) b
compTurnRight (Path
tag, b
cmd) = (Path, b) -> Message (Path, b) b
forall a b. a -> Message a b
Low (Direction -> Path -> Path
turn Direction
R Path
tag, b
cmd)