       (set-process-query-on-exit-flag process nil)
       (process-send-string process ":set -fobject-code\n")
       (process-send-string process ":set prompt \"\\4\"\n")
+      ;; The following settings give us expanded splices on load
+      (process-send-string process ":set -XTemplateHaskell\n")
+      (process-send-string process ":set -ddump-splices\n")
       (with-current-buffer buffer
         (erase-buffer)
         (setq intero-targets targets)

(define-key intero-mode-map (kbd "C-c C-l") 'intero-repl-load)
(define-key intero-mode-map (kbd "C-c C-z") 'intero-repl)
(define-key intero-mode-map (kbd "C-c C-r") 'intero-apply-suggestions)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global variables/state

        (forward-line (1- line))
        (forward-char (1- col))
        t))))

(defun intero-get-expansion-at-pos (string buffer line start)
  "Take output from the background intero process as STRING, the current BUFFER, LINE and the the column of the START of the thing to expand.  Return the expansion of the the thing at START.  If there is no expansion at START, then return nil."
  (let* ((column-regex (format "\\(%s\\|%s\\)" start (1+ start)))
	 ;; ghci varies the column number of an expanded template haskell
	 ;; expression according to whether it is parenthesised or not;
	 ;; column-regex matches on either possibility.
	 (regex (concat (intero-localize-path (intero-temp-file-name buffer))
			(format ":%s:" line)
			(format "%s" column-regex)
			"\\(-[0-9]+\\)?: Splicing expression[ \t\n]*"
			"\\(\\( .*\n\\)+\\)")))
    (when (string-match regex string)
      (match-string 3 string))))

(defun intero-expand-splice-at-point ()
  "Show the expansion of the template haskell splice at point."
  (interactive)
  (let* ((line (line-number-at-pos (point)))
	 (pos (intero-thing-at-point))
	 (beg (car pos))
	 (start-column (save-excursion (goto-char beg)
				       (current-column))))
    (intero-async-call
     'backend
     (concat ":l " (intero-localize-path (intero-temp-file-name)))
     (list :file-buffer (current-buffer)
	   :line line
	   :start start-column)
     (lambda (state string)
       (let* ((buffer (plist-get state :file-buffer))
	      (line (plist-get state :line))
	      (start (plist-get state :start))
	      (expansion (intero-get-expansion-at-pos string buffer line start)))
	 (when expansion
	   (message (intero-fontify-expression expansion))))))))

(defun intero-restart ()
  "Simply restart the process with the same configuration as before."
