       (indent-to (shm-node-start-column current))
       (insert "| "))
      ;; Indent after or at the = (an rhs).
-     ((or (string= "Rhs" (shm-node-type-name parent))
-          (string= "Rhs" (shm-node-type-name current))
-          (string= "GuardedAlt" (shm-node-type-name parent)))
+     ((and parent
+           (or (string= "Rhs" (shm-node-type-name parent))
+               (string= "Rhs" (shm-node-type-name current))
+               (string= "GuardedAlt" (shm-node-type-name parent))))
       (newline)
       (indent-to (+ (shm-indent-spaces)
                     (shm-node-start-column (cdr (shm-node-parent parent-pair))))))
      ;; When in a field update.
-     ((string= "FieldUpdate" (shm-node-type-name parent))
+     ((and parent
+           (string= "FieldUpdate" (shm-node-type-name parent)))
       (newline)
       (indent-to (+ (shm-node-start-column parent)
                     (shm-indent-spaces))))
      ;; When in an alt list
-     ((string= "GuardedAlts" (shm-node-type-name current))
+     ((and parent
+           (string= "GuardedAlts" (shm-node-type-name current)))
       (newline)
       (indent-to (+ (shm-node-start-column parent)
                     (shm-indent-spaces))))
      ;; When in a case alt.
-     ((string= "GuardedAlts" (shm-node-type-name parent))
+     ((and parent
+           (string= "GuardedAlts" (shm-node-type-name parent)))
       (newline)
       (let ((alt (cdr (shm-node-parent parent-pair))))
         (indent-to (+ (shm-node-start-column alt)
                       (shm-indent-spaces)))))
      ;; Copy infix operators similar to making new list/tuple
      ;; separators
-     ((eq 'InfixApp (shm-node-cons parent))
+     ((and parent
+           (eq 'InfixApp (shm-node-cons parent)))
       (let* ((operand-pair (shm-node-previous current-pair))
              (operand (cdr operand-pair))
              (string (buffer-substring-no-properties (shm-node-start operand)

          (newline)
          (indent-to column)))))
     ;; Indent for sum types
     ((eq 'DataDecl (shm-node-cons parent))
      (newline)
      (indent-to (shm-node-start-column current))
      (delete-char -2)

        (indent-to (shm-node-start-column operand))
        (insert string " ")))
     ;; Infix operators
     ((and parent
           (eq 'InfixApp (shm-node-cons parent)))
      (newline)
      (indent-to (+ (shm-node-start-column parent))))
     ;; Default indentation just copies the current node's indentation
