Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel main without closing ghci

Tags:

haskell

I'm working on a web server using Scotty. I can run ghci and keep using :r to get it to reload my code, but if I even run main I cant' restart the web server without killing ghci.

How can I cancel main without closing ghci? Is there a better way to handle web servers and automatically restart them?

like image 788
Sean Clark Hess Avatar asked Nov 21 '25 12:11

Sean Clark Hess


1 Answers

Invoke :set args <arg> ... in ghci to set the arguments that will be returned by System.getArgs.

Then, using the async package, launch the server in ghci with something like a <- async main.

Later invoke cancel a to kill the server.

See also this link that explains how to reload code even while the server is running.

like image 62
danidiaz Avatar answered Nov 24 '25 05:11

danidiaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!