Skip to content

Commit 013f25a

Browse files
committed
Define helper function to determine response type
1 parent 2532074 commit 013f25a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

haskell-commands.el

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,5 +970,28 @@ execusion."
970970
(remove-hook
971971
'post-command-hook #'hs-utils/async-update-post-command-flag t)))
972972

973+
(defun hs-utils/parse-repl-response (r)
974+
"Parse response R from REPL and return special kind of result.
975+
The result is response string itself with speacial property
976+
response-type added.
977+
978+
This property could be of the following:
979+
980+
+ unknown-command
981+
+ option-missing
982+
+ interactive-error
983+
+ success"
984+
(let ((first-line (car (split-string r "\n"))))
985+
(cond
986+
((string-match-p "^unknown command" first-line) 'unknown-command)
987+
((string-match-p "^Couldn't guess that module name. Does it exist?"
988+
first-line)
989+
'option-missing)
990+
((string-match-p "^<interactive>:" first-line) 'interactive-error)
991+
(t 'success))))
992+
993+
994+
995+
973996
(provide 'haskell-commands)
974997
;;; haskell-commands.el ends here

0 commit comments

Comments
 (0)