Homework to practice Foldable, Traversable, State/Parser, Monad Transformers and Combinators, Arrow, and Lens
Homework to practice Foldable, Traversable, State Monad Transformer, and Lens
In this homework you will implement some functions to work with maps…
QuadTree
data structure an instance of Functor
, Foldable
, and Traversable
(think about delegation) and implement other prepated functions. You can use prepared lenses for data types QuadTree
and Quadrant
to make your code more readable. Spoiler: the most challenging part is fromMatrix
.Coords
, Map
, and other related stuff. Few functions are not implemented and are waiting for you to be done. Try to make it as simple as possible. Recall syntactic sugar, point free style, and pattern matching. Again, lenses are ready for you…StateT
, you can rework it or just investigate and use as is. You have to implement 3 normal functions which are used in state manipulation and for the CLI.When everything is done, you should be able to travel with:
% stack exec traveler
The Map Traveler
╔════════════════════════════════════════╗
║^ @ ~~~~~~ ░░░░░░░░║
║ ▓ ^ ~~~~~~~ ░░░░░░║
║ ^ ▓ ~~~~~~~ ^ ░░░░║
║ ███████ ▓ ^^ ~~~~~~~ ░░░░║
║ █ █ ▓ ~~~~~ ^ ░░░░║
║ ███████ ▓ ^ ~~ ║
║ ^^ ▓▓▓▓▓▓▓▓▓▓▓▓▓ ~~ ║
║ ^ ▓ ~~ ║
║ ^ ^ ▓ ~~ ║
║^^ ^ ^^ ▓ ~~~~ ║
║^^ ^ ░░░ ░░░░ ▓ ~~~ ║
║^^^^ ░░░░░░░░ ▓▓ ~~ ║
╚════════════════════════════════════════╝
What direction do you want to go?
w
╔════════════════════════════════════════╗
║^ @ ~~~~~~ ░░░░░░░░║
║ ▓ ^ ~~~~~~~ ░░░░░░║
║ ^ ▓ ~~~~~~~ ^ ░░░░║
║ ███████ ▓ ^^ ~~~~~~~ ░░░░║
║ █ █ ▓ ~~~~~ ^ ░░░░║
║ ███████ ▓ ^ ~~ ║
║ ^^ ▓▓▓▓▓▓▓▓▓▓▓▓▓ ~~ ║
║ ^ ▓ ~~ ║
║ ^ ^ ▓ ~~ ║
║^^ ^ ^^ ▓ ~~~~ ║
║^^ ^ ░░░ ░░░░ ▓ ~~~ ║
║^^^^ ░░░░░░░░ ▓▓ ~~ ║
╚════════════════════════════════════════╝
What direction do you want to go?
s
╔════════════════════════════════════════╗
║^ ▓ ~~~~~~ ░░░░░░░░║
║ @ ^ ~~~~~~~ ░░░░░░║
║ ^ ▓ ~~~~~~~ ^ ░░░░║
║ ███████ ▓ ^^ ~~~~~~~ ░░░░║
║ █ █ ▓ ~~~~~ ^ ░░░░║
║ ███████ ▓ ^ ~~ ║
║ ^^ ▓▓▓▓▓▓▓▓▓▓▓▓▓ ~~ ║
║ ^ ▓ ~~ ║
║ ^ ^ ▓ ~~ ║
║^^ ^ ^^ ▓ ~~~~ ║
║^^ ^ ░░░ ░░░░ ▓ ~~~ ║
║^^^^ ░░░░░░░░ ▓▓ ~~ ║
╚════════════════════════════════════════╝
What direction do you want to go?
q
Byeee!
You should be able to move with w a s d step by step thru walkable places in the map.
The CLI and some other trivial parts are not tested so you can improve it if you want. Also you can create other maps, options, and so on. You can also build some game on top of this and use some ncurses library.
This project is licensed under the MIT License - see the LICENSE
file for more details.