Skip to content

Seperating haskell and cabal mode #1879

Open

Description

@puff-paddy

Various major modes for haskell exist that are not haskell-mode, (haskell-ts-mode, haskell-ng-mode), and users of both are forced to pull haskell-mode since it provides a major mode for cabal. Would it be practical to support cabal-mode from haskell-mode in its own package?

Activity

  1. purcell commented on Sep 8, 2025

    @purcell
    Member

    Probably, yes. The steps we'd need to follow would be approximately the following:

    • Create a new repo called cabal-mode with cabal.el, starting out as a copy of haskell-cabal.el.
    • Change all the haskell-cabal- identifier prefixes to cabal-.
    • Remove the (require 'haskell-utils) and figure out what would break. If anything, fix it if practical.
    • Publish a corresponding cabal package on MELPA and/or ELPA.
    • Remove haskell-cabal.el from haskell-mode, and perhaps (though probably not) make haskell-mode depend on the cabal package.

    This is also relevant to my interests, because I'm personally working with haskell-ts-mode instead of haskell-mode. However, I'm not working much with Haskell at the moment, so I'm unlikely to work on the above steps myself.

  2. webdevred commented on Sep 8, 2025

    @webdevred
    Collaborator

    Probably, yes. The steps we'd need to follow would be approximately the following:

    * Create a new repo called `cabal-mode` with `cabal.el`, starting out as a copy of `haskell-cabal.el`.
    
    * Change all the `haskell-cabal-` identifier prefixes to `cabal-`.
    
    * Remove the `(require 'haskell-utils)` and figure out what would break. If anything, fix it if practical.
    
    * Publish a corresponding `cabal` package on MELPA and/or ELPA.
    
    * Remove `haskell-cabal.el` from `haskell-mode`, and _perhaps_ (though probably not) make `haskell-mode` depend on the `cabal` package.
    

    This is also relevant to my interests, because I'm personally working with haskell-ts-mode instead of haskell-mode. However, I'm not working much with Haskell at the moment, so I'm unlikely to work on the above steps myself.

    I spent a lot of time writing code for my personal projects during the summer. Also it feels like haskell-mode is a big project, it is hard to get a good understanding of it, I dont know where to start. But I would love to get into haskell-mode and I would be like to help with this issue. I can create a new repo, in my account I guess since I dont have haskell organization permissions and separate the cabal mode into that and ping you when I am getting somewhere.

  3. puff-paddy commented on Sep 19, 2025

    @puff-paddy
    Author

    @webdevred how is it going with separating the cabal mode?

  4. purcell commented on Sep 22, 2025

    @purcell
    Member

    That sounds good, @webdevred — ping me if you need anything, or when there's anything to show. In due course we could then fold it back into this org for community maintenance.

  5. webdevred commented on Sep 27, 2025

    @webdevred
    Collaborator

    Hello @puff-paddy,
    Update from my side:
    So far I found three definitions in haskell-utils.el used by haskell-cabal.el, they are
    haskell-mode-toggle-interactive-prompt-state along with its toggle variable haskell-mode-interactive-prompt-state and haskell-utils-read-directory-name.

    haskell-utils-read-directory-name, however is only used in haskell-cabal-get-dir, a function which is not used inside haskell-cabal.el but it is used in haskell-session.el.

    This is is example of where haskell-mode-toggle-interactive-prompt-state is used:

    (defun haskell-cabal-find-or-create-source-file ()
      "Open the source file this line refers to."
      (interactive)
      (let* ((src-dirs (append (haskell-cabal-subsection-entry-list
                                (haskell-cabal-section) "hs-source-dirs")
                               '("")))
             (base-dir (file-name-directory (buffer-file-name)))
             (filename (haskell-cabal-line-filename)))
        (when filename
          (let ((candidates
                 (delq nil (mapcar
                            (lambda (dir)
                              (let ((file (haskell-cabal-join-paths base-dir
                                                                    dir
                                                                    filename)))
                                (when (and (file-readable-p file)
                                           (not (file-directory-p file)))
                                  file)))
                            src-dirs))))
            (if (null candidates)
                (unwind-protect
                    (progn
                      (haskell-mode-toggle-interactive-prompt-state)
                      (let* ((src-dir
                              (haskell-cabal-join-paths base-dir
                                                        (or (car src-dirs) "")))
                             (newfile (haskell-cabal-join-paths src-dir filename))
                             (do-create-p (y-or-n-p (format "Create file %s ?" newfile))))
                        (when do-create-p
                          (find-file-other-window newfile ))))
                  (haskell-mode-toggle-interactive-prompt-state t))
              (find-file-other-window (car candidates)))))))
    

    haskell-cabal-find-or-create-source-file is bound to C-c C-f in the cabal mode.

    I plan to clean up my code and publish my code later, maybe tomorrow or during the coming week and proceed to make a package in melpa or elpa.

  6. self-assigned this
    on Sep 30, 2025
  7. puff-paddy commented on Oct 8, 2025

    @puff-paddy
    Author

    No worries, take your time

  8. webdevred commented on Oct 22, 2025

    @webdevred
    Collaborator

    No worries, take your time

    Update: I have published my cabal-mode package as a draft, we will probably discuss a bit how to improve it before merging it into melpa.

  9. puff-paddy commented on Nov 21, 2025

    @puff-paddy
    Author

    Since cabal mode has been merged to melpa thanks to @webdevred , are there plans to remove haskell-cabal.el and perhaps add cabal-mode as a dependency

  10. webdevred commented on Nov 21, 2025

    @webdevred
    Collaborator

    Since cabal mode has been merged to melpa thanks to @webdevred , are there plans to remove haskell-cabal.el and perhaps add cabal-mode as a dependency

    I would be happy help with this part as well, if @purcell thinks we should do this.

  11. purcell commented on Nov 24, 2025

    @purcell
    Member

    Yeah, it would make sense to remove haskell-cabal.el. In a purist sense, haskell-mode shouldn't really depend on the cabal-mode package. Over time, haskell-mode has turned into a big Haskell IDE bundle, which isn't super desirable IMO, and static package dependencies make it hard to swap out non-core portions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions