Hi all,
Possibly the wrong place to ask (as this is quite a general Haskell question), but it's quite specific to Cloud Haskell (and quite important too), so I'm going out on a limb...
I've implemented Erlang's gen_server, generic server behaviour for Cloud Haskell. This is a core Erlang behaviour, used to ensure that processes which reside in supervision trees behave in a consistent manner. You're not forced to only use gen_server processes in supervision trees, but you've got to follow the "contract" or they don't work properly, and using gen_server has a lot of other advantages too....
Anyway, gen_server (or Managed Process, as it's called in Cloud Haskell) is based on a generic "server loop" that deals with the message receiving and replying parts of a process, whilst your code focusses on the "business logic" (if you like), and that server loop is a recursive constant process.
I'm a little concerned that *my* server loop might not be tail recursive, since I've had bug reports of "large message payloads don't get delivered" which could either be a network-transport bug, or simply my code is wrong and runs out of stack space...
How do I check to see if my code is tail recursive? Is there some flag I can pass to ghc (cabal, stack, whatever) to look at intermediate code and find out?
Please don't tell me I should be using the monadic `forever $ do' construct instead - whilst this may be true, handling the ongoing state would be problematic, and besides my code has to evaluate to a value eventually, once the server process terminates (in the case where it doesn't crash) so that's not an option afaict.
Any pointers in the right direction would be hugely appreciated!!!
Cheers,
Tim