Created
November 29, 2013 01:08
-
-
Save Fuuzetsu/7700214 to your computer and use it in GitHub Desktop.
insert type of Haskell functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun haskell-insert-type () | |
"Insert the type of the function on the previous line. | |
You have to be be on the first line of the function. | |
Use `haskell-insert-type-infix' for infix functions. | |
It uses the Haskell inferior process in order to get the class constraints | |
as well" | |
(interactive) | |
(save-excursion | |
(beginning-of-line) | |
(zap-up-to-char 1 ?\s) | |
(yank) | |
(let ((func-type (inferior-haskell-type (yank-peek)))) | |
(beginning-of-line) | |
(newline) | |
(previous-line) | |
(insert func-type)))) | |
(defun haskell-insert-type-infix () | |
"Insert a type of the infix function on the previous line. | |
Also see `haskell-insert-type'. Note that this works by using the spaces between | |
arguments to determine the of function so it will fail if your first argument | |
contains a space, for example when matching on a String. | |
It uses the Haskell inferior process in order to get the class constraints | |
as well. Make sure you have loaded the file using `inferior-haskell-load-file'." | |
(interactive) | |
(save-excursion | |
(beginning-of-line) | |
(zap-up-to-char 1 ?\s) | |
(yank) | |
(forward-char) | |
(zap-up-to-char 1 ?\s) | |
(yank) | |
(let ((func-type (inferior-haskell-type | |
(concat "(" (yank-peek) ")")))) | |
(beginning-of-line) | |
(newline) | |
(previous-line) | |
(insert func-type)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment