haskell - Is it safe to use trace inside a STM stransaction? -


i have transaction failing indefinitely reason, , use trace instructions inside. example, print state of mvar's before executing transaction in fragment:

    data_out <- atomically $          rtg_state <- taketmvar ready_to_go          jobdescr hashid url <- t.readtbchan next_job_descr         case rtg_state of              ready_rtg n ->                 puttmvar ready_to_go $ processing_rtg n                 puttmvar start_harvester_browser hashid                 puttmvar next_test_url_to_check_chan  hashid                 puttmvar next_harvest_url hashid                 return (n,hashid,url)             _ -> retry 

would make program segfault or miss-behave?

as long use trace debug purposes should ok. general rule, assume in final production-ready version of program there no traces around.

you never observe segfaults trace. "unsafety" stems injecting observable effects in pure code. e.g., in stm, when transaction retries, effects assumed rolled back. if trace used send message user, can't roll back. if output of trace triggers missile launch, have deal international side effects. if trace instead signals developer "fyi, code doing x", not part of core logic of program, , fine.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -