 
 (defun merlin-type-of-expression-local (bounds exp)
   "Get the type of an expression inside the local context"
-  (cons 
-   bounds
-   (merlin-is-return 
-    (merlin-send-command "type"
-                         (list "expression" exp "at" 
-                               (merlin-unmake-point (point)))))))
+  (if (and bounds exp)
+      (cons 
+       bounds
+       (merlin-is-return 
+        (merlin-send-command "type"
+                             (list "expression" exp "at" 
+                                   (merlin-unmake-point (point))))))))
 
 (defun merlin-type-of-expression-global (bounds exp)
   "Get the type of an expression globally"
-  (cons
-   bounds
-   (merlin-is-return (merlin-send-command "type" (list "expression" exp)))))
+  (if (and bounds exp)
+      (cons
+       bounds
+       (merlin-is-return (merlin-send-command "type" (list "expression" exp)))))
 
 
 (defun merlin-type-of-expression (bounds exp)

overlay is displayed and module types are displayed in another
buffer. Otherwise only value type are displayed, and without
overlay"
  (if bounds
      (let ((result (merlin-type-of-expression bounds
                                               (buffer-substring-no-properties 
                                                (car bounds) (cdr bounds)))))
        (cond
         ((not (cdr result))
          (if (not quiet)
              (message "<no information>"))) ;; no types
         ((and (not (merlin-is-long (cdr result)))
               (not quiet))
          (merlin-create-overlay 'merlin-type-overlay
                                 (caar result) (cdar result)
                                 'next-error "1 sec")
          (message "%s" (cdr result)))
         ((not (merlin-is-long (cdr result)))
          (message "%s: %s"
                   (buffer-substring-no-properties (caar result) (cdar result))
                   (cdr result)))
         ((not quiet)
          (display-buffer merlin-type-buffer)
          (with-current-buffer merlin-type-buffer
            (erase-buffer)
            (insert (cdr result))))))))
  

(defun merlin-show-type-of-region ()

         (merlin-is-return 
          (merlin-send-command "type" (list "at" (merlin-unmake-point (point)))))))
    (if ret
        (let ((bounds (merlin-make-bounds ret))
              (type (cdr (assoc 'type ret))))
          (if (and
               (>= (car bounds) (point))
               (<= (point) (cdr bounds)))
              (cons bounds type)
            nil)))))
          

