     (complete-with-action action merlin-completion-annotation-table string pred)))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; COMPANY MODE SUPPORT
-;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; COMPANY MODE SUPPORT ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun merlin--company-doc-buffer (candidate)
+  "Computes the /doc/ of CANDIDATE and returns the buffer where it printed it"
+  ; TODO: at the moment "doc" is understood as "type", but hopefully someday we
+  ; will access ocamldoc comments and display that.
+  (let ((typ (get-text-property 0 'merlin-meta candidate)))
+    (if (not (equal typ " <module>"))
+      (merlin--type-display-in-buffer typ)
+      (let* ((expr (substring-no-properties candidate))
+             (loc  (merlin-unmake-point (point)))
+             (cmd  (list 'type 'expression expr 'at loc))
+             (res  (merlin-send-command cmd)))
+        (merlin--type-display-in-buffer res)))
+    (get-buffer merlin-type-buffer-name)))
 
 (defun merlin-company-backend (command &optional arg &rest ignored)
     (interactive (list 'interactive))

          (post-completion
           (prin1 command)
           (prin1 arg)
           (minibuffer-message "%s: %s" arg (get-text-property 0 'merlin-meta arg)))
          (meta
           (prin1 command)
           (prin1 arg)

          (annotation
           (prin1 command)
           (prin1 arg)
           (concat " : " (get-text-property 0 'merlin-meta arg)))
          )))

;;;;;;;;;;;;;;;;;;;;;;;;;;;
