The default lambda character in emacs haskell mode?

Does anyone know how I can print λ instead of \ using haskell in emacs. I know that you can use haskell-font-lock-lock characters, but I find it hard for others to read - the arrows are too small!

Is there an easy way to move the rest of the keys?

+7
source share
2 answers

You can do it:

(defun pretty-lambdas-haskell () (font-lock-add-keywords nil `((,(concat "\\(" (regexp-quote "\\") "\\)") (0 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) nil)))))) (add-hook 'haskell-mode-hook 'pretty-lambdas-haskell) 

This adds a lambda as a keyword, which means that it will not appear in escape sequences in strings, for example (TODO: this is not the case after changing things). ,(make-char 'greek-iso8859-7 107) , of course, is equivalent to , but you must make sure that your Emacs init file is encoded as unicode in this case.

You can also enable full blocking of character fonts and use the font better (read: with wider arrows) like Pragmata Pro , Inconsolata or Ubuntu Monospace . I use the following code to select a good font:

 (defun font-existsp (font) "Check to see if the named FONT is available." (if (null (x-list-fonts font)) nil t)) (require 'cl) (defun font-avail (fonts) "Finds the available fonts." (remove-if-not 'font-existsp fonts)) (defvar font-preferences '("PragmataPro" "Inconsolata" "DejaVu Sans Mono" "Bitstream Vera Sans Mono" "Anonymous Pro" "Menlo" "Consolas")) (unless (eq window-system nil) (let ((fonts (font-avail font-preferences))) (unless (null fonts) (set-face-attribute 'default nil :font (car fonts))))) 
+2
source

You can also solve the problem with something like

 (eval-after-load 'haskell-font-lock '(setq haskell-font-lock-symbols-alist (delq nil (mapcar (lambda (rewrite) (if (member (car rewrite) '("->" "<-")) nil rewrite)) haskell-font-lock-symbols-alist)))) 

which should contain all comparisons, except those that change "->" to "→" and "<-" to "←".

+2
source

All Articles