I presume this is a follow up to What is the format of GHC hp profile?.
In general there is no way to automatically detect every infinite loop. In practice and not specific to GHC, I think it is commonly reasonable to detect them manually by looking at the CPU and memory usage. This particular case should exhaust memory because it is not tail recursive (at least, I think that's the reason). Something like action x y z = action x y z
won't allocate and so would spin indefinitely, maxing the CPU with no increase in memory usage. It would be up to you to have an expectation of execution time and memory usage and investigate any deviations.
I haven't tried this, but if you suspect an infinite loop perhaps you could use the xc
RTS option and interrupt the execution to get a stack trace.