It accepts any function that returns IAnimal, not just factories. This can be risky in the long run.
It decentralizes factories. This will eventually end up writing plenty of duplicate code, and possible local or private functions that do similar but slightly different initializations, probably when you need more customization.
I feel some anti-pattern issues:
You can see where it is going.
This is no different from the factory pattern, which accepts any object that implements
IAnimalFactory
. I don't think there's any risk involved.I don't follow you. How does the factory pattern (or my functional version of it) lead to duplicate code? An example might help.