This minor mode provides structured editing operations based on the syntax of Haskell. In short-hand it's called SHM and throughout the codebase, too. It acts a bit like, and is heavily inspired by, paredit-mode for Emacs.
Its features work by parsing the current declaration with an
executable called structured-haskell-mode
, and then creates marks
for all the nodes' positions in the buffer.
Feature | Explanation
--- | --- | ---
| Indenting: shm/newline-indent
takes the current node and its type into consideration giving very predictable and useful behaviour.
| Going to parent: shm/goto-parent
jumps to the start of the parent.
| Going to parent end: shm/goto-parent-end
jumps to the end of the parent.
| Adding a list item: shm/newline-indent
(C-j
) will automatically add a comma when inside a list.
| Adding operands: shm/add-operand
(C-+
) will look at the current node and add another operand in the direction the cursor is leaning towards.
| Auto-reindenting: Typing and deleting will automatically re-indent dependent code blocks.
| Raising: shm/raise
raises the current node to replace its parent. If its direct parent is not the same expression type, it continues up the tree.
| Re-indenting: shm/newline-indent
and shm/delete-indentation
allow you to bring nodes inwards or outwards relative to the parent.
| Record syntax: Creating new elements with record syntax, like lists (and tuples) automatically adds the right separators.
| Transposition: shm/tranpose
will swap two sibling nodes.
| Copy/pasting: shm/kill
and shm/yank
take indentation into account, and automatically normalize so that re-inserting will indent properly.