Evaluate for a fixed amount of time or fail

There’s a fundamental problem with using Async or Lwt for what you describe here. That’s because both of those are cooperative threading libraries, and what you want here is to time out if a given function runs for too long, which is considerably trickier.

What one might do here depends a fair bit on the context, so maybe you can say a bit more about what you’re trying to achieve? You could run the code in a separate thread, but terminating threads cleanly is tricky to do in a portable way (which is why Java retracted support for this feature long ago.) A multi-process solution will give you cleaner termination semantics, but is a little more work to set up.

So understanding what this is for would help.

y