#+TITLE: Programming Haskell #+AUTHOR: Howard X. Abrams #+DATE: 2022-08-24 #+FILETAGS: :emacs: A literate programming file for configuring Emacs to use [[https://www.haskell.org/][Haskell]] . #+begin_src emacs-lisp :exports none ;;; ha-programming-haskell --- configuring for haskell. -*- lexical-binding: t; -*- ;; ;; © 2022-2023 Howard X. Abrams ;; Licensed under a Creative Commons Attribution 4.0 International License. ;; See http://creativecommons.org/licenses/by/4.0/ ;; ;; Author: Howard X. Abrams ;; Maintainer: Howard X. Abrams ;; Created: August 24, 2022 ;; ;; While obvious, GNU Emacs does not include this file or project. ;; ;; *NB:* Do not edit this file. Instead, edit the original literate file at: ;; ~/other/hamacs/ha-programming-haskell.org ;; And tangle the file to recreate this one. ;; ;;; Code: #+end_src * Introduction While “they” claim a [[https://www.haskell.org/tutorial/][Gentle Introduction]], it doesn’t look /fun/. I bought the book, [[http://learnyouahaskell.com/chapters][Learn You a Haskell for Great Good!]], which looks better. Before an /Emacsian/ can dive into a new language, one needs to get an Emacs environment working. First, get it installed. On a Mac, do something like: #+begin_src sh brew install haskell-stack #+end_src Which installs the [[https://docs.haskellstack.org/][Haskell Stack]] project that is basically an interface to the /kitchen sink/. And then run: #+begin_src sh stack setup #+end_src And then you get access to an interactive session in a virtual environment with: #+begin_src sh stack ghci #+end_src * Haskell Mode Seems that the venerable [[https://github.com/haskell/haskell-mode][haskell-mode]] is the best. #+begin_src emacs-lisp (use-package haskell-mode :custom (haskell-process-type 'stack-ghci)) #+end_src See [[https://input-output-hk.github.io/adrestia/resources/Emacs][this configuration]] for some advanced features. The [[https://github.com/mihaimaruseac/hindent][hindent package]] looks interesting: #+begin_src emacs-lisp (use-package hindent :custom (hindent-style "johan-tibell") :hook (haskell-mode . #'hindent-mode)) #+end_src * Haskell and Org #+begin_src emacs-lisp (use-package ob-haskell :straight (:type built-in) :config (add-to-list 'org-babel-load-languages '(haskell . t))) #+end_src And let’s see if this works: #+begin_src haskell :results replace value nums = filter (> 2) [1 .. 5] zip nums ['a' .. 'e'] #+end_src #+RESULTS: | 3 | a | | 4 | b | | 5 | c | * Technical Artifacts :noexport: Let's =provide= a name so we can =require= this file: #+begin_src emacs-lisp :exports none (provide 'ha-programming-haskell) ;;; ha-programming-haskell.el ends here #+end_src #+DESCRIPTION: configuring Emacs. #+PROPERTY: header-args:sh :tangle no #+PROPERTY: header-args:emacs-lisp :tangle ~/.emacs.d/elisp/ha-programming-haskell.el #+PROPERTY: header-args :results none :eval no-export :comments no mkdirp yes #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil date:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js