module Route(compTurnRight, compTurnLeft, compPath) where import Message(Message(..)) import Path(turn,Direction(..)) compPath :: ([Direction], b) -> b -> (Either (Message ([Direction], b) b) (Message ([Direction], b) b) -> b) -> b compPath ([Direction] path, b ev) b wrongaddr Either (Message ([Direction], b) b) (Message ([Direction], b) b) -> b c = case [Direction] path of Direction L:[Direction] tag' -> Either (Message ([Direction], b) b) (Message ([Direction], b) b) -> b c forall a b. (a -> b) -> a -> b $ forall a b. a -> Either a b Left (forall a b. a -> Message a b Low ([Direction] tag', b ev)) Direction R:[Direction] tag' -> Either (Message ([Direction], b) b) (Message ([Direction], b) b) -> b c forall a b. (a -> b) -> a -> b $ forall a b. b -> Either a b Right (forall a b. a -> Message a b Low ([Direction] tag', b ev)) [Direction] _ -> b wrongaddr compTurnLeft :: ([Direction], b) -> Message ([Direction], b) b compTurnLeft ([Direction] tag, b cmd) = forall a b. a -> Message a b Low (Direction -> [Direction] -> [Direction] turn Direction L [Direction] tag, b cmd) compTurnRight :: ([Direction], b) -> Message ([Direction], b) b compTurnRight ([Direction] tag, b cmd) = forall a b. a -> Message a b Low (Direction -> [Direction] -> [Direction] turn Direction R [Direction] tag, b cmd)