{"id":400,"date":"2010-04-06T20:29:56","date_gmt":"2010-04-06T19:29:56","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/?p=400"},"modified":"2010-04-06T20:29:56","modified_gmt":"2010-04-06T19:29:56","slug":"quickrun-for-incremental-haskellemacs-development","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2010\/04\/06\/quickrun-for-incremental-haskellemacs-development\/","title":{"rendered":"Quickrun for incremental haskell\/emacs development"},"content":{"rendered":"<p>I often add quick test functions (like &#8220;testme&#8221;) inside the haskell module I&#8217;m developing.  They&#8217;re short-lived and soon turn into tests.  But I find this approach works better than putting the same lines into ghci because they &#8216;persist&#8217; for longer.<\/p>\n<p>Since I do this so often, and I use emacs, I automated it.  With the following code, I now just hit C-c C-c and emacs loads my module into ghci and runs my test function.  Stick a C-u in front, and it&#8217;ll let you choose a different function as the default to run.<\/p>\n<pre>\r\n(add-hook 'haskell-mode-hook 'my-haskell-hook)\r\n\r\n(defun my-haskell-hook ()\r\n  (local-set-key \"\\C-c\\C-c\" 'haskell-quickrun)\r\n)\r\n\r\n(defvar haskell-quickrun-command \"main\")\r\n\r\n(defun haskell-quickrun (arg)\r\n  (interactive \"P\")\r\n\r\n  (unless (null arg)\r\n\t(setq haskell-quickrun-command (read-from-minibuffer \"Function to run: \")))\r\n\r\n  (inferior-haskell-load-file)\r\n  (inferior-haskell-send-command (inferior-haskell-process) haskell-quickrun-command)\r\n  (end-of-buffer-other-window 0)\r\n)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I often add quick test functions (like &#8220;testme&#8221;) inside the haskell module I&#8217;m developing. They&#8217;re short-lived and soon turn into tests. But I find this approach works better than putting the same lines into ghci because they &#8216;persist&#8217; for longer. Since I do this so often, and I use emacs, I automated it. With the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-400","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":1,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}