If you load some modules with pymain, such as:
[pymain|
import json
import importlib
import my_business_module
Unfortunately, even after a ghci reload (e.g. :reload), the python context stays initialised and hence the import are NOT reloaded. This can be confusing (I spent a bit of time tuning my haskell code and reloading without sucess and even with confusing errors before realizing that I needed to reload the repl).
A workaround is to use importlib to reload the modules:
[pymain|
import json
import importlib
import my_business_module
importlib.reload(my_business_module)
That's a bit slower and comes with few gurantee (the reload model of python is not perfect), but it saves a full ghci reload in many context.
If you agree, I'll add a line in haddock in the section Troubleshooting.
If you load some modules with
pymain, such as:Unfortunately, even after a ghci reload (e.g.
:reload), the python context stays initialised and hence theimportare NOT reloaded. This can be confusing (I spent a bit of time tuning my haskell code and reloading without sucess and even with confusing errors before realizing that I needed to reload the repl).A workaround is to use
importlibto reload the modules:That's a bit slower and comes with few gurantee (the reload model of python is not perfect), but it saves a full ghci reload in many context.
If you agree, I'll add a line in haddock in the section
Troubleshooting.