[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspect-0.0.8 index info |
Date: |
Tue, 5 Oct 2021 23:59:57 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 103e75875b37f4358b74a192166f3d970000f6c3
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
expose some more hsinspect-0.0.8 index info
---
haskell-tng-hsinspect.el | 34 ++++++++++++++++++++++++++--------
test/haskell-tng-hsinspect-test.el | 34 ++++++++++++++++++++++++++++++----
2 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 6d50f03..f2fb3c0 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -61,15 +61,18 @@ A prefix argument ensures that caches are flushes."
(sym (match-string 2 sym)))
;; FIXME types and data constructors
(when-let (hit (haskell-tng--hsinspect-import-popup index sym))
- (haskell-tng--import-symbol (car hit) fqn)))
+ (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 (car hit) nil (cdr hit))))))
+ (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.
+;; TODO expand out wildcards in pattern matches. We can calculate the type by
+;; looking at the names of the other data constructors that have been used.
+
(defun haskell-tng--hsinspect-qualify (imports sym)
(cdar
(last
@@ -80,17 +83,20 @@ A prefix argument ensures that caches are flushes."
(defun haskell-tng--hsinspect-import-popup (index sym)
(when-let ((hits (haskell-tng--hsinspect-import-candidates index sym)))
;; TODO special case one hit
- (when-let* ((entries (mapcar 'car hits)) ;; TODO include function name
+ ;; TODO show more context, like the type
+ (when-let* ((entries (mapcar (lambda (el) (alist-get 'module el)) hits))
(selected (popup-menu* entries)))
- (seq-find (lambda (el) (equal (car el) selected)) hits))))
+ (seq-find (lambda (el) (equal (alist-get 'module el) selected)) hits))))
(defun haskell-tng--hsinspect-import-candidates (index sym)
- "Return a list of (module . symbol)"
+ "Return an list of alists with keys: unitid, module, name, type.
+When using hsinspect-0.0.8, also: class, export, flavour."
;; TODO threading/do syntax
;; TODO alist variable binding like RecordWildcards
(seq-mapcat
(lambda (pkg-entry)
- (let ((modules (alist-get 'modules pkg-entry)))
+ (let ((unitid (alist-get 'unitid pkg-entry))
+ (modules (alist-get 'modules pkg-entry)))
(seq-mapcat
(lambda (module-entry)
(let ((module (alist-get 'module module-entry))
@@ -98,8 +104,20 @@ A prefix argument ensures that caches are flushes."
;;(message "MODULE= %s" module)
(seq-mapcat
(lambda (entry)
- (let ((name (alist-get 'name entry)))
- (when (equal name sym) `(,(cons module name)))))
+ (let ((name (alist-get 'name entry))
+ (type (alist-get 'type entry))
+ (class (alist-get 'class entry))
+ (export (alist-get 'export entry))
+ (flavour (alist-get 'flavour entry)))
+ (when (equal name sym)
+ ;; TODO add the hsinspect-0.0.8 bits
+ `(((unitid . ,unitid)
+ (module . ,module)
+ (name . ,name)
+ (type . ,type)
+ (class . ,class)
+ (export . ,export)
+ (flavour . ,flavour))))))
ids)))
modules)))
index))
diff --git a/test/haskell-tng-hsinspect-test.el
b/test/haskell-tng-hsinspect-test.el
index 3bbccac..37aca5a 100644
--- a/test/haskell-tng-hsinspect-test.el
+++ b/test/haskell-tng-hsinspect-test.el
@@ -41,15 +41,41 @@
(should
(equal
(haskell-tng--hsinspect-import-candidates index "throw")
- '(("Control.Exception.Base" . "throw")
- ("Control.Exception" . "throw")
- ("GHC.Exception" . "throw"))))
+ '(((unitid . "base")
+ (module . "Control.Exception.Base")
+ (name . "throw")
+ (type . "forall a e. Exception e => e -> a")
+ (class . id)
+ (export (unitid . "base")
+ (module . "GHC.Exception"))
+ (flavour))
+ ((unitid . "base")
+ (module . "Control.Exception")
+ (name . "throw")
+ (type . "forall a e. Exception e => e -> a")
+ (class . id)
+ (export (unitid . "base")
+ (module . "GHC.Exception"))
+ (flavour))
+ ((unitid . "base")
+ (module . "GHC.Exception")
+ (name . "throw")
+ (type . "forall a e. Exception e => e -> a")
+ (class . id)
+ (export)
+ (flavour)))))
;; operator search
(should
(equal
(haskell-tng--hsinspect-import-candidates index ">$<")
- '(("Data.Functor.Contravariant" . ">$<"))))
+ '(((unitid . "base")
+ (module . "Data.Functor.Contravariant")
+ (name . ">$<")
+ (type . "forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b
-> f a")
+ (class . id)
+ (export)
+ (flavour)))))
;; TODO type search
;; TODO constructor search
- [nongnu] elpa/haskell-tng-mode a788ab2 209/385: more efficient layout caching, (continued)
- [nongnu] elpa/haskell-tng-mode a788ab2 209/385: more efficient layout caching, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f7e8040 213/385: = ends a type sig, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fe9d65d 222/385: helper for yatemplates, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect support, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 658ddb6 251/385: docs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect` per project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b1c664b 364/385: allow hsinspect population in the background, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ce17d96 376/385: new hsinspect release, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode eb6b487 357/385: test fqn-at-point and fix a longstanding bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspect-0.0.8 index info,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive commands, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e3c6dc6 336/385: follow re-exports, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9904e72 366/385: jump-to-definition works inside the project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1c68e79 381/385: requires emacs 27, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 55d8e69 385/385: upgrade hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 97e4a66 379/385: bump hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3870bf1 367/385: time to remove the cabal v2- prefixes, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 47f1f9f 180/385: lex CONSYM correctly, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9bc086a 187/385: easier install, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4f40db3 218/385: fast-tags is stack compatible by default, ELPA Syncer, 2021/10/06