{"id":7747,"date":"2015-10-21T00:23:33","date_gmt":"2015-10-21T00:23:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/21\/sol-reserve\/"},"modified":"2015-10-21T00:23:33","modified_gmt":"2015-10-21T00:23:33","slug":"sol-reserve","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/21\/sol-reserve\/","title":{"rendered":"sol\/reserve"},"content":{"rendered":"<p><strong>DISCLAIMER:<\/strong> This is early stage software. It is already functional and useful, but it still has some rough edges.<\/p>\n<p><code>reserve<\/code> provides code reloading for Haskell web applications. You can run you application with <code>reserve<\/code> during development and code changes will take immediate effect.<\/p>\n<h2>Requirements<\/h2>\n<p><code>reserve<\/code> can reload arbitrary Haskell web applications. The only requirement is that your application works with <code>ghci<\/code>.<\/p>\n<h2>Examples<\/h2>\n<h3>Scotty<\/h3>\n<p>Create a file <code>app.hs<\/code> with the following content:<\/p>\n<pre><code>{-# LANGUAGE OverloadedStrings #-}\nimport Web.Scotty\n\nmain :: IO ()\nmain = scotty 3000 $ do\n  get \"\/\" $ do\n    text \"hello\\n\"\n<\/code><\/pre>\n<pre><code>$ reserve app.hs\n<\/code><\/pre>\n<p>Make a request to http:\/\/localhost:12000, modify <code>app.hs<\/code>, reload!<\/p>\n<h3>Snap (sandboxed)<\/h3>\n<pre><code>$ mkdir my-project &amp;&amp; cd my-project\n$ cabal sandbox init\n$ cabal install snap\n$ cabal exec snap init barebones\n$ cabal exec -- reserve -p 8000\n<\/code><\/pre>\n<p>Make a request to http:\/\/localhost:12000, modify <code>src\/Main.hs<\/code>, reload!<\/p>\n<h2>Customization<\/h2>\n<p>By default <code>reserve<\/code> assumes that the <code>Main<\/code> module of your application is at <code>src\/Main.hs<\/code>. You can customize this by passing the path to your <code>Main<\/code> module to <code>reserve<\/code>:<\/p>\n<pre><code>$ reserve src\/app.hs\n<\/code><\/pre>\n<p>By default <code>reserve<\/code> assumes that your application listens on port <code>3000<\/code>. You can customize this by passing <code>--port<\/code> to <code>reserve<\/code>:<\/p>\n<pre><code>$ reserve --port 8000\n<\/code><\/pre>\n<p>By default <code>reserve<\/code> serves your application on port <code>12000<\/code>. You can customize this by passing <code>--reserve-port<\/code> to <code>reserve<\/code>:<\/p>\n<pre><code>$ reserve --reserve-port 4040\n<\/code><\/pre>\n<p>You can pass command-line arguments to your application by separating them with <code>--<\/code>:<\/p>\n<pre><code>$ reserve src\/app.hs -- --mode development\n<\/code><\/pre>\n<p><code>reserve<\/code> uses <code>ghci<\/code> to run your application. If your application requires any addition GHC options, you can put them into <code>.\/.ghci<\/code>:<\/p>\n<pre><code>$ echo \":set -isrc\" &gt;&gt; .ghci\n$ reserve src\/app.hs\n<\/code><\/pre>\n<p><code>reserve<\/code> works with Cabal sandboxes, just run it with <code>cabal exec -- reserve<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DISCLAIMER: This is early stage software. It is already functional and useful, but it still has some rough edges. reserve provides code reloading for Haskell web applications. You can run you application with reserve during development and code changes will take immediate effect. Requirements reserve can reload arbitrary Haskell web applications. The only requirement is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7747","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7747"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7747\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}