diff --git a/elisp/ghc-check.el b/elisp/ghc-check.el index 009a5b5..81a2650 100644 --- a/elisp/ghc-check.el +++ b/elisp/ghc-check.el @@ -184,7 +184,8 @@ (ghc-ins-mod sym))) ((string-match "Not in scope: `\\([^'\n\0]+\\)'" data) (let ((sym (match-string 1 data))) - (if (y-or-n-p (format "Import module for %s?" sym)) + (if (or (string-match "\\." sym) ;; qualified + (y-or-n-p (format "Import module for %s?" sym))) (ghc-ins-mod sym) (unless (re-search-forward "^$" nil t) (goto-char (point-max)) diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index a24acde..3bac402 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -20,13 +20,20 @@ (ghc-ins-mod expr))) (defun ghc-ins-mod (expr) - (let ((mods (ghc-function-to-modules expr))) + (let (prefix fun mods) + (if (not (string-match "^\\([^.]+\\)\\\.\\([^.]+\\)$" expr)) + (setq fun expr) + (setq prefix (match-string 1 expr)) + (setq fun (match-string 2 expr))) + (setq mods (ghc-function-to-modules fun)) (if (null mods) (message "No module guessed") (let ((mod (ghc-completing-read "Module name (%s): " mods))) (save-excursion (ghc-goto-module-position) - (insert "import " mod " (" (ghc-enclose expr) ")\n")))))) + (if prefix + (insert "import qualified " mod " as " prefix "\n") + (insert "import " mod " (" (ghc-enclose expr) ")\n"))))))) (defun ghc-completing-read (fmt lst) (let* ((def (car lst))