Sometimes I put a lot of effort into a software package, only to realize later that I was aiming in the wrong direction. This is not always a failure.
That kind of experience often gives me useful insights about where I should have aimed in the first place. And then I have an opportunity to try again, refocusing into another direction.
I suspect that this process of iterating from “failure” is fairly common. People don’t like to talk about the things they tried that didn’t work, but those attempts often end up being productive in the long run.
When it comes to this sort of thing, I have my own little tongue-in-cheek mantra: You never learn from your successes.