* haskell-ts-modeA haskell mode that uses treesitter.* Screenshot[[./ss.png]]The above screenshot is indented coloured using haskell-ts-mode, withprettify-symbols-mode enabled.* Usage=C-c C-r= to open REPL=C-c C-c= to send code to repl=C-M-q= Indent paragraph* Featuresan overview of the features are:- Syntax highliting- Indentation- Imenu support- REPL (C-c r in the mode to run)- Prettify symbols mode support* Comparasion with haskell-modeThe more interesting features are:- Logical syntax highlighting: - Only arguments that can be used in functions are highlighted, eg in `f (_:(a:[])) only 'a' is highlighted, as it is the only variable that is captured that can be used in body of function - The return type of a function is highlighted - All new variabels are(or should be) highlighted, this includes generators, lambda args. - highlighting the '=' operaotr in guarded matches correctly, this would be stupidly hard in regexp based syntax- Unlike haskell-mode, quasi quotes are understood and do not confuse the mode, thanks to treesitter- Predictable (but less powerful) indentation: haskell-mode's indentation works in a cyclical way, it cycles through where you might want indentation. haskell-ts-mode, meanwhile relies on you to set the concrete syntax tree changing whitespace.- More perfomant, this is especially seen in longer files- Much much less code, haskell mode has accumlated 30,000 lines of features to do with all things haskell related, this mode just keeps the scope to basic major mode stuff, and leaves other stuff for external packages.* Motivationhaskell-mode contains nearly 30k lines of code, and isabout 30 years old. Therefore, a lot of stuff emacs has gained theability to do in those years, haskell-mode already has implementedthem.In 2018, a mode called haskell-tng-mode was made to solve some ofthese problems. However because of haskell's syntax, it too becamevery complex and required a web of dependencies.Both these modes ended up practically parsing haskells syntax toimplement indentation, so I thought why not use tree sitter?* InstallationThe package is avaiable on elpa, you can install it using:M-x package-install RET haskell-ts-mode RET#+begin_src elisp(add-to-list 'load-path "path/to/haskell-ts-mode")(require 'haskell-ts-mode)#+end_src* CustomizationIf colour is too much or too less for you, adjusttreesit-font-lock-level accordingly.If you want to highlight signature declarations (disabled by default),add the following to your init file:#+begin_src emacs-lisp(setq haskell-ts-highlight-signature t)#+end_src** how to disable haskell-ts-mode indentation#+begin_src emacs-lisp(setq haskell-ts-use-indent nil)#+end_src** Pretify symbols modeprettify symbols mode can be used to replace common symbols withunicode alternatives.#+begin_src emacs-lisp(add-hook 'haskell-ts-mode 'prettify-symbols-mode)#+end_src** Adjusting font lock levelset haskell-ts-font-lock-level accordingly.** Language serverhaskell-ts-mode is compatiable with lsp-haskell.To enable eglot support, use the following code in your init.el:#+begin_src emacs-lisp(with-eval-after-load 'eglot (haskell-ts-setup-eglot))#+end_src* TODO and limitations- Imenu support for functions with multiple definitionsLimitations: _Proper indenting of multiline signatures_: thetreesitter grammer does not flatten the signautes, rather leaves themto the standard infix interpretatoin. This makes indentation hard, asit will mean the only way to check if the the signature node is anancestor of node at point is to perfom a recursive ascent, which ishorrible for perfomance.