diff --git a/Cabal.hs b/Cabal.hs
--- a/Cabal.hs
+++ b/Cabal.hs
@@ -18,7 +18,7 @@
 ----------------------------------------------------------------
 
 importDirs :: [String]
-importDirs = ["..","../..","../../..","../../../..","../../../../.."]
+importDirs = [".","..","../..","../../..","../../../..","../../../../.."]
 
 initializeGHC :: Options -> FilePath -> [String] -> Bool -> Ghc (FilePath,LogReader)
 initializeGHC opt fileName ghcOptions logging = do
diff --git a/GHCMod.hs b/GHCMod.hs
--- a/GHCMod.hs
+++ b/GHCMod.hs
@@ -2,16 +2,18 @@
 
 module Main where
 
-import CabalDev (modifyOptions)
 import Browse
+import CabalDev (modifyOptions)
 import Check
 import Control.Applicative
 import Control.Exception
 import Data.Typeable
+import Data.Version
 import Info
 import Lang
 import Lint
 import List
+import Paths_ghc_mod
 import Prelude
 import System.Console.GetOpt
 import System.Directory
@@ -25,7 +27,7 @@
 ghcOptHelp = " [-g GHC_opt1 -g GHC_opt2 ...] "
 
 usage :: String
-usage =    "ghc-mod version 1.0.4\n"
+usage =    "ghc-mod version " ++ showVersion version ++ "\n"
         ++ "Usage:\n"
         ++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l]\n"
         ++ "\t ghc-mod lang [-l]\n"
diff --git a/Info.hs b/Info.hs
--- a/Info.hs
+++ b/Info.hs
@@ -107,9 +107,15 @@
 setContextFromTarget :: Ghc Bool
 setContextFromTarget = do
     ms <- depanal [] False
+
+#if __GLASGOW_HASKELL__ >= 704
+    top <- map (IIModule . ms_mod) <$> filterM isTop ms
+    setContext top
+#else
     top <- map ms_mod <$> filterM isTop ms
     setContext top []
-    return (top /= [])
+#endif
+    return (not . null $ top)
   where
     isTop ms = lookupMod `gcatch` returnFalse
       where
diff --git a/elisp/Makefile b/elisp/Makefile
--- a/elisp/Makefile
+++ b/elisp/Makefile
@@ -1,5 +1,5 @@
 SRCS = ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el \
-       ghc-command.el ghc-info.el
+       ghc-command.el ghc-info.el ghc-ins-mod.el
 EMACS = emacs
 
 TEMPFILE  = temp.el
diff --git a/elisp/ghc-command.el b/elisp/ghc-command.el
--- a/elisp/ghc-command.el
+++ b/elisp/ghc-command.el
@@ -21,8 +21,8 @@
     (message "Nothing to be done"))))
 
 (defun ghc-insert-module-template ()
-  ;; xxx mod from filename...
   (let ((mod (file-name-sans-extension (buffer-name))))
+    (aset mod 0 (upcase (aref mod 0)))
     (insert "module " mod " where\n")))
 
 (defun ghc-sort-lines (beg end)
diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el
new file mode 100644
--- /dev/null
+++ b/elisp/ghc-ins-mod.el
@@ -0,0 +1,53 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; ghc-ins-mod.el
+;;;
+
+;; Author:  Kazu Yamamoto <Kazu@Mew.org>
+;; Created: Dec 27, 2011
+
+;;; Code:
+
+(defvar ghc-hoogle-command "hoogle")
+
+(defvar ghc-hoogle-keywords '("data" "server" "combine" "convert" "test" "dump" "rank" "log"))
+
+(defun ghc-insert-module ()
+  (interactive)
+  (if (not (ghc-which ghc-hoogle-command))
+      (message "\"%s\" not found" ghc-hoogle-command)
+    (let* ((expr0 (thing-at-point 'symbol))
+	   (expr (ghc-read-expression expr0)))
+      (if (member expr ghc-hoogle-keywords)
+	  (message "\"%s\" not allowed" expr)
+	(let ((mods (ghc-function-to-modules expr)))
+	  (if (null mods)
+	      (message "No module guessed")
+	    (let* ((first (car mods))
+		   (ini (cons first 0))
+		   (mod (if (= (length mods) 1)
+			    first
+			  (completing-read "Module name: " mods nil t ini))))
+	      (save-excursion
+		(ghc-goto-module-position)
+		(insert "import " mod "\n")))))))))
+
+(defun ghc-goto-module-position ()
+  (goto-char (point-max))
+  (if (re-search-backward "^import" nil t)
+      (forward-line)
+    (if (re-search-backward "^module" nil t)
+	(forward-line)
+      (goto-char (point-min)))))
+
+(defun ghc-function-to-modules (fn)
+  (with-temp-buffer
+    (call-process ghc-hoogle-command nil t nil fn)
+    (goto-char (point-min))
+    (let ((regex (concat "^\\([a-zA-Z0-9.]+\\) " fn " "))
+	  ret)
+      (while (re-search-forward regex nil t)
+	(setq ret (cons (match-string 1) ret)))
+      (nreverse ret))))
+
+(provide 'ghc-ins-mod)
diff --git a/elisp/ghc.el b/elisp/ghc.el
--- a/elisp/ghc.el
+++ b/elisp/ghc.el
@@ -16,7 +16,7 @@
 
 ;;; Code:
 
-(defconst ghc-version "1.0.4")
+(defconst ghc-version "1.0.5")
 
 ;; (eval-when-compile
 ;;  (require 'haskell-mode))
@@ -26,6 +26,7 @@
 (require 'ghc-info)
 (require 'ghc-flymake)
 (require 'ghc-command)
+(require 'ghc-ins-mod)
 (require 'dabbrev)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -50,6 +51,7 @@
 (defvar ghc-info-key        "\C-c\C-i")
 (defvar ghc-check-key       "\C-x\C-s")
 (defvar ghc-toggle-key      "\C-c\C-c")
+(defvar ghc-module-key      "\C-c\C-m")
 (defvar ghc-hoogle-key      (format "\C-c%c" (ghc-find-C-h)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -74,6 +76,7 @@
     (define-key haskell-mode-map ghc-sort-key        'ghc-sort-lines)
     (define-key haskell-mode-map ghc-check-key       'ghc-save-buffer)
     (define-key haskell-mode-map ghc-toggle-key      'ghc-flymake-toggle-command)
+    (define-key haskell-mode-map ghc-module-key      'ghc-insert-module)
     (define-key haskell-mode-map ghc-hoogle-key      'haskell-hoogle)
     (ghc-comp-init)
     (setq ghc-initialized t)))
diff --git a/ghc-mod.cabal b/ghc-mod.cabal
--- a/ghc-mod.cabal
+++ b/ghc-mod.cabal
@@ -1,5 +1,5 @@
 Name:                   ghc-mod
-Version:                1.0.4
+Version:                1.0.5
 Author:                 Kazu Yamamoto <kazu@iij.ad.jp>
 Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp>
 License:                BSD3
@@ -20,10 +20,10 @@
 Build-Type:             Simple
 Data-Dir:               elisp
 Data-Files:             Makefile ghc.el ghc-func.el ghc-doc.el ghc-comp.el
-                        ghc-flymake.el ghc-command.el ghc-info.el
+                        ghc-flymake.el ghc-command.el ghc-info.el ghc-ins-mod.el
 Executable ghc-mod
   Main-Is:              GHCMod.hs
-  Other-Modules:        List Browse Cabal CabalDev Check Info Lang Lint Types ErrMsg
+  Other-Modules:        List Browse Cabal CabalDev Check Info Lang Lint Types ErrMsg Paths_ghc_mod
   if impl(ghc >= 6.12)
     GHC-Options:        -Wall -fno-warn-unused-do-bind
   else
