Does ReScript has a way to implement an generics retry function?

Like Tenacity in Python Pip.

I Don’t know how to write this generic function

This is relatively simple to implement with a few higher order functions: https://rescript-lang.org/try?code=DYUwLgBAtghgHgJXAJwJYgM4QLwQKwBQBokyKAngKJwDGIADmKgPYB2OEAFAGYA0XASgE4AfBADeBCBBIQyYNJg5lunAAwCpEAO4ALVKAgKAriAlbpC8uem2IqzXYC+EGjDA1dN2wB8IZ7DFUbjkUdAwAOho2MBBWMCwAHmh4JAVw7ztpeUVI6Pi4hOUwzCiYwqwAaggARgtbFxBgDDNJLNtkGFQWzhBHLKd6welBweJwUKtqOkYWVhqOHn4YYUDvWRyM3BV1fr0DMxNW+qtM21UVodd3TzO-AKCQzdL82PiklMQSrDb2ydyygV3sV0i9ysDqnV2o1msc-nIuj0+vURkMtKMiBsKNMGEw2AAmRZ8CAwfgAI1WYl+WNBWG2IFUGi0+0MRzOp1+dgu5P6I2uHi8nIg91EEGC-3CgLeRWSsC+tLOdmeeXBRXptKlFQgkJREBhLUVHURIF6vIaaNRYxAtFxcwgAGVmFAQJRkMhmMhxqQSjAyaAAGLGVg0PHsdXIKg22ZsTicSkSTrdE2O52u93IAROTRAA

I would point out that the decorators in python are not the same as the @ decorators you see in ReScript. They can accomplish similar things and you may be able to implement a similar retry API as tenacity, although I would recommend being more explicit and just using higher order functions.

One thing that also may be different to the python API is that in ReScript the arity (the number of arguments) of a function is fixed at compile time. You can see this in the playground link, you need to write a function that receives 1, 2, 3 etc. arguments.

1 Like