Function: haskell-cabal-enum-targets

haskell-cabal-enum-targets is a natively compiled function defined in haskell-cabal.el.

Signature

(haskell-cabal-enum-targets &optional PROCESS-TYPE)

Documentation

Enumerate .cabal targets.

PROCESS-TYPE determines the format of the returned target.

Source Code

;; Defined in /nix/store/9lz2mhw95f9fqxr9mnq46k3f6qz3aq83-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-mode-20260904.1042/haskell-cabal.el
(defun haskell-cabal-enum-targets (&optional process-type)
  "Enumerate .cabal targets.
PROCESS-TYPE determines the format of the returned target."
  (let ((cabal-file (haskell-cabal-find-file))
        (process-type (if process-type process-type 'ghci)))
    (when (and cabal-file (file-readable-p cabal-file))
      (with-temp-buffer
        (insert-file-contents cabal-file)
        (haskell-cabal-mode)
        (goto-char (point-min))
        (let ((matches)
              (package-name (haskell-cabal--get-field "name")))
          (haskell-cabal-next-section)
          (while (not (eobp))
            (if (haskell-cabal-source-section-p (haskell-cabal-section))
                (let* ((section (haskell-cabal-section))
                       (component-type (haskell-cabal-section-name section))
                       (val (car (split-string
                                  (haskell-cabal-section-value section)))))
                  (if (equal (downcase component-type) "library")
                      (let ((lib-target (if (eq 'stack-ghci process-type)
                                            (concat package-name ":lib")
                                          (concat "lib:" package-name))))
                        (push lib-target matches))
                    (push (concat  (when (eq 'stack-ghci process-type)
                                     (concat package-name ":"))
                                   (haskell-cabal-map-component-type component-type)
                                   ":"
                                   val)
                          matches))))
            (haskell-cabal-next-section))
          (reverse matches))))))