A hayloft is used for more permanent storage of hay. It is sheltered from the weather and where a modern-day attic would be.
Hay lofts are analogous to attics in that they provide a sheltered area for storing goods, specifically hay, which is similar to how an attic is used for storing household items.