Full source code ⋅ Previous chapter
This chapter is going to be the easiest one so far since here we are just gather composing things together.
To receive commands we need to access outer World, to shift a list without losing progress we need State - so let's joint them:
From now on we can use both World and State in the same expression!
We write this program for console, that's why we should clear previous inputs and turn off character buffering:
We store task titles in State, so we should get it contents:
Challenge: how control flow is going to change if you use Apply behaviour instead?
So that we can print them:
User would see a sequence of task titles with a cursor which they could move:
Once we got a proper command, let's update the state:
Challenge: how control flow is going to change if you use Lease behaviour instead?
If we stop at this step, our program would just finish, but we don't want that: