| Your version doesn't work. * all but the first results are not arrays, so the `.map` function doesn't apply * doesn't handle async operations * catches ALL exceptions here, whereas my code only handles statically typed and well-defined errors * doesn't include the GPT-generated message and messages from the first steps in the error * doesn't include retry functionality I appreciate this argument and time you've taken to read my code and write this counter-argument. Please don't mistake my direct code for animosity, I clearly see that you're a smart person even though I think you're wrong about this. Also, the fp-ts doesn't add any runtime performance overhead here. It's a couple of extra function calls for a call that has an async operation that likely takes 30 seconds (GPT-4 is slow). Obviously, if I was writing code that runs thousands of times per second, I would not use FP. |
It does.
It was also somewhat tongue-in-cheek, and a five-second copy-paste of your code.
> all but the first results are not arrays, so the `.map` function doesn't apply
Unless you return arrays from all functions.
Not that different from wrapping every result into seventeen layers of functional abstractions. What do you think flow or flatMapEither does?
> doesn't include the GPT-generated message and messages from the first steps in the error
Of course it does. That's what the catch is for.
Or you could use an additional map if you want.
> Also, the fp-ts doesn't add any runtime performance overhead here. It's a couple of extra function calls
Of course it adds runtime performance overhead. Any additional function call adds a performance overhead. And in your case it's dozens of functions wrapping trivial functionality.
> Obviously, if I was writing code that runs thousands of times per second, I would not use FP.
Then why use it here? If the alternative is more readable, more traceable, has better stack traces for errors, doesn't require an unstable ever changing dependency...