branch: elpa/haskell-tng-mode commit 38ed1b73a5bdcb3c0ecd354e9bc5a3c766c83221 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
import types --- haskell-tng-hsinspect.el | 8 +++++--- test/haskell-tng-hsinspect-test.el | 14 +++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el index f2fb3c0..2eda5b7 100644 --- a/haskell-tng-hsinspect.el +++ b/haskell-tng-hsinspect.el @@ -59,13 +59,15 @@ A prefix argument ensures that caches are flushes." (if (string-match (rx bos (group (+ anything)) "." (group (+ (not (any ".")))) eos) sym) (let* ((fqn (match-string 1 sym)) (sym (match-string 2 sym))) - ;; FIXME types and data constructors (when-let (hit (haskell-tng--hsinspect-import-popup index sym)) (haskell-tng--import-symbol (alist-get 'module hit) fqn))) (when-let (hit (haskell-tng--hsinspect-import-popup index sym)) ;; TODO add parens around operators ;; TODO add the type around data constructors (requires hsinspect changes) - (haskell-tng--import-symbol (alist-get 'module hit) nil (alist-get 'name hit)))))) + (pcase (alist-get 'class hit) + ('tycon (haskell-tng--import-symbol (alist-get 'module hit) nil (alist-get 'type hit))) + ;; FIXME con + (_ (haskell-tng--import-symbol (alist-get 'module hit) nil (alist-get 'name hit)))))))) ;; TODO expand out pattern matches (function defns and cases) based on the cons ;; for a type obtained from the Index. @@ -109,7 +111,7 @@ When using hsinspect-0.0.8, also: class, export, flavour." (class (alist-get 'class entry)) (export (alist-get 'export entry)) (flavour (alist-get 'flavour entry))) - (when (equal name sym) + (when (or (equal name sym) (equal type sym)) ;; TODO add the hsinspect-0.0.8 bits `(((unitid . ,unitid) (module . ,module) diff --git a/test/haskell-tng-hsinspect-test.el b/test/haskell-tng-hsinspect-test.el index 37aca5a..4cf4632 100644 --- a/test/haskell-tng-hsinspect-test.el +++ b/test/haskell-tng-hsinspect-test.el @@ -77,8 +77,20 @@ (export) (flavour))))) - ;; TODO type search + ;; type / typeclass search + (should + (equal + (haskell-tng--hsinspect-import-candidates index "Contravariant") + '(((unitid . "base") + (module . "Data.Functor.Contravariant") + (name) + (type . "Contravariant") + (class . tycon) + (export) + (flavour . "class"))))) + ;; TODO constructor search + ;;(message "%S" (haskell-tng--hsinspect-import-candidates index "Contravariant")) )) ;; TODO tests for 0.0.7 data