Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive-Haskell multiline support #1353

Open
Pitometsu opened this issue Jun 3, 2016 · 34 comments
Open

Interactive-Haskell multiline support #1353

Pitometsu opened this issue Jun 3, 2016 · 34 comments

Comments

@Pitometsu
Copy link

By default, Interactive-Haskell change prompt, but not prompt2, so it looks strange, when try to use multiline input:

λ> :set +m
λ> let
*Main FunnyPrint Main| 
λ> 
@Pitometsu
Copy link
Author

Pitometsu commented Jun 3, 2016

Shouldn't prompt2 in this case be something like |? Also I have nicer version for prompt, 2 lines, imported modules on first, and separator of command prompt on second at begin.

λ Prelude ¬
λ > let a =
λ |       [0..100]
λ | 
a :: (Enum t, Num t) => [t]
(0.00 secs, 0 bytes)
λ Prelude ¬
λ > a
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
     20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
     38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
     56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
     74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
     92, 93, 94, 95, 96, 97, 98, 99, 100]
it :: (Enum t, Num t) => [t]
(0.01 secs, 0 bytes)
λ Prelude ¬
λ > 

But it break Interactive-Haskell and haskell-doc, don't know, why (in plain stack ghci it looks awesome and work well. #1352

@fice-t
Copy link
Contributor

fice-t commented Jun 3, 2016

Are you using the latest snapshot release? The way prompt2 is handled changed recently, so it fits more with the current prompt.

@Pitometsu
Copy link
Author

Try to install recent version, got error:

if [ ! -d $(dirname build-24.5.2/build-flag) ]; then mkdir $(dirname build-24.5.2/build-flag); fi
/run/current-system/sw/bin/emacs --eval "(add-to-list 'load-path (expand-file-name \"tests/compat\") 'append)" --eval "(when (boundp 'load-prefer-newer) (setq load-prefer-newer t))" --batch -Q -L . --eval '(setq byte-compile-error-on-warn t)'                  \
     --eval "(defun byte-compile-dest-file (filename)               \
                  (concat (file-name-directory filename) \"build-\" emacs-version \"/\" \
                            (file-name-nondirectory filename) \"c\"))'"         \
     -f batch-byte-compile haskell-font-lock.el haskell-customize.el haskell-completions.el haskell-checkers.el haskell-session.el haskell-string.el haskell-repl.el highlight-uses-mode.el haskell-process.el haskell-collapse.el inf-haskell.el haskell-presentation-mode.el haskell-unicode-input-method.el haskell-mode.el haskell-load.el ghci-script-mode.el ghc-core.el w3m-haddock.el haskell-move-nested.el haskell-debug.el haskell-navigate-imports.el haskell-menu.el haskell-interactive-mode.el haskell.el haskell-cabal.el haskell-compile.el haskell-sandbox.el haskell-ghc-support.el haskell-doc.el haskell-compat.el haskell-align-imports.el haskell-commands.el haskell-indent.el haskell-decl-scan.el haskell-modules.el haskell-hoogle.el haskell-indentation.el haskell-complete-module.el haskell-utils.el haskell-c2hs.el haskell-lexeme.el haskell-sort-imports.el

In toplevel form:
haskell-font-lock.el:445:1:Warning: Unused lexical argument `args'
haskell-font-lock.el:445:1:Warning: Unused lexical argument `fmt'
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-font-lock.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-customize.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-completions.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-checkers.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-session.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-string.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-repl.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/highlight-uses-mode.elc

In toplevel form:
haskell-process.el:488:1:Warning: Unused lexical argument `e'
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-process.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-collapse.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/inf-haskell.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-presentation-mode.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-unicode-input-method.elc

In toplevel form:
haskell-mode.el:1171:1:Error: the function `haskell-mode-stylish-buffer' is not known to be defined.

In toplevel form:
haskell-load.el:93:1:Warning: Unused lexical argument `e'
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-load.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/ghci-script-mode.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/ghc-core.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/w3m-haddock.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-move-nested.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-debug.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-navigate-imports.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-menu.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-interactive-mode.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-cabal.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-compile.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-sandbox.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-ghc-support.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-doc.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-compat.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-align-imports.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-commands.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-indent.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-decl-scan.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-modules.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-hoogle.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-indentation.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-complete-module.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-utils.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-c2hs.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-lexeme.elc
Wrote /home/netsu/.emacs.d/el-get/haskell-mode/build-24.5.2/haskell-sort-imports.elc
Makefile:60: recipe for target 'build-24.5.2/build-flag' failed
make: *** [build-24.5.2/build-flag] Error 1
Debugger entered--Lisp error: (error "el-get: make el-get could not build haskell-mode [make EMACS=/run/current-system/sw/bin/emacs all]")
  signal(error ("el-get: make el-get could not build haskell-mode [make EMACS=/run/current-system/sw/bin/emacs all]"))
  error("el-get: %s %s" "make" "el-get could not build haskell-mode [make EMACS=/run/current-system/sw/bin/emacs all]")
  byte-code("\203\314��@��A�\306   \307\"\306 \310\"\306 \311\"\312
!\205\"\313
!�@\306 \314\"�A\306    \315\"\211�B\203=�\316\306  \317\"!\202A�\306   \317\"�C�B\203R�\320\321\306    \322\"\"\202V�\306  \322\"�D\323    \324�E#�F\306   \325\"�G�\203r�\326\327�!!\202t��H�H�C\204��\330\331!\210�F\203R�\332\333�\"\210�B\203\222�\334\202\223�\335�I�G\205\235�\336\337!\211�J\205\312��J\340\341\342!!�K�L\343\216r�Kq\210\344�G!c)r�Kq\210\345\346\211�L\346\347%\210,�M\350\351\f\"�M\352�I�C�J
\353�D&��N\306  \354\"�(\306    \355\"�O�P\203\375�\350\356r
q\210\357 )\"\210�N\347=\203
\350\360�(\"\210\202��\361\362 
\"\210\330\363\f�O#\210�J\203$�\364�J!\210
\203,�\313
!\210\n\203A�\365�Q\\�Q\366�R\n�S#)\202M�\367�S!\205M��S�R!.�\202\311�\332\370�\"\210�B\203`�\371\202a�\372�I\346�T\352�I\f
�C�D%�U\373\374 \"\210\375�U\376�V#\210\375�U\377�R#\210\375�U\201W��S#\210\375�U\201X�\n#\210�G\203\261�\201Y��U\344�G!\"\210\201Z��U!\210\201[��U\201\\\"\210�A\205\310�\201]��U�A\"+.
\207\367�S!\205\330��S�R!\207" [commands c next cdir cname cbuf plist-get :default-directory :command-name :buffer-name get-buffer kill-buffer :process-filter :shell el-get-shell-quote-program :program mapcar el-get-maybe-shell-quote-argument :args el-get-plist-get-with-default :sync :stdin file-name-as-directory expand-file-name error "el-get: :program argument cannot be nil" el-get-verbose-message "Running commands synchronously: %S" call-process-shell-command call-process make-temp-file "el-get" get-buffer-create generate-new-buffer-name " *temp file*" ((byte-code "\301�!\203\n\302�!\210\301\207" [temp-buffer buffer-name kill-buffer] 2)) el-get-print-to-string write-region nil 0 message "el-get is waiting for %S to complete" apply t :message :error "%S" buffer-string "el-get: %s" set-window-buffer ...] 8)
  el-get-start-process-list(haskell-mode ((:command-name "make" :buffer-name "*el-get-build: haskell-mode*" :default-directory "/home/netsu/.emacs.d/el-get/haskell-mode/" :shell t :sync sync :program "/run/current-system/sw/bin/make" :args ("EMACS=/run/current-system/sw/bin/emacs" "all") :message "el-get-build haskell-mode: make EMACS=/run/current-system/sw/bin/emacs all ok." :error "el-get could not build haskell-mode [make EMACS=/run/current-system/sw/bin/emacs all]")) (lambda (package) (el-get-install-or-init-info package (quote build)) (funcall (lambda (package) (let ((bytecomp-files (when el-get-byte-compile (el-get-assemble-files-for-byte-compilation package)))) (el-get-start-process-list package (list (el-get-byte-compile-process package "*el-get-build: haskell-mode*" "/home/netsu/.emacs.d/el-get/haskell-mode/" sync bytecomp-files)) (function el-get-post-install-build)))) package)))
  el-get-build(haskell-mode (("make" "EMACS=/run/current-system/sw/bin/emacs" "all")) nil sync el-get-post-install-build)
  el-get-post-install(haskell-mode)
  byte-code("\203\314��@��A�\306   \307\"\306 \310\"\306 \311\"\312
!\205\"\313
!�@\306 \314\"�A\306    \315\"\211�B\203=�\316\306  \317\"!\202A�\306   \317\"�C�B\203R�\320\321\306    \322\"\"\202V�\306  \322\"�D\323    \324�E#�F\306   \325\"�G�\203r�\326\327�!!\202t��H�H�C\204��\330\331!\210�F\203R�\332\333�\"\210�B\203\222�\334\202\223�\335�I�G\205\235�\336\337!\211�J\205\312��J\340\341\342!!�K�L\343\216r�Kq\210\344�G!c)r�Kq\210\345\346\211�L\346\347%\210,�M\350\351\f\"�M\352�I�C�J
\353�D&��N\306  \354\"�(\306    \355\"�O�P\203\375�\350\356r
q\210\357 )\"\210�N\347=\203
\350\360�(\"\210\202��\361\362 
\"\210\330\363\f�O#\210�J\203$�\364�J!\210
\203,�\313
!\210\n\203A�\365�Q\\�Q\366�R\n�S#)\202M�\367�S!\205M��S�R!.�\202\311�\332\370�\"\210�B\203`�\371\202a�\372�I\346�T\352�I\f
�C�D%�U\373\374 \"\210\375�U\376�V#\210\375�U\377�R#\210\375�U\201W��S#\210\375�U\201X�\n#\210�G\203\261�\201Y��U\344�G!\"\210\201Z��U!\210\201[��U\201\\\"\210�A\205\310�\201]��U�A\"+.
\207\367�S!\205\330��S�R!\207" [commands c next cdir cname cbuf plist-get :default-directory :command-name :buffer-name get-buffer kill-buffer :process-filter :shell el-get-shell-quote-program :program mapcar el-get-maybe-shell-quote-argument :args el-get-plist-get-with-default :sync :stdin file-name-as-directory expand-file-name error "el-get: :program argument cannot be nil" el-get-verbose-message "Running commands synchronously: %S" call-process-shell-command call-process make-temp-file "el-get" get-buffer-create generate-new-buffer-name " *temp file*" ((byte-code "\301�!\203\n\302�!\210\301\207" [temp-buffer buffer-name kill-buffer] 2)) el-get-print-to-string write-region nil 0 message "el-get is waiting for %S to complete" apply t :message :error "%S" buffer-string "el-get: %s" set-window-buffer ...] 8)
  el-get-start-process-list(haskell-mode (nil (:command-name "*git submodule update*" :buffer-name "*git clone haskell-mode*" :default-directory "/home/netsu/.emacs.d/el-get/haskell-mode/" :program "/nix/var/nix/profiles/default/bin/git" :args ("--no-pager" "submodule" "update" "--init" "--recursive") :message "git submodule update ok" :error "Could not update git submodules")) el-get-post-install)
  byte-code("\203\314��@��A�\306   \307\"\306 \310\"\306 \311\"\312
!\205\"\313
!�@\306 \314\"�A\306    \315\"\211�B\203=�\316\306  \317\"!\202A�\306   \317\"�C�B\203R�\320\321\306    \322\"\"\202V�\306  \322\"�D\323    \324�E#�F\306   \325\"�G�\203r�\326\327�!!\202t��H�H�C\204��\330\331!\210�F\203R�\332\333�\"\210�B\203\222�\334\202\223�\335�I�G\205\235�\336\337!\211�J\205\312��J\340\341\342!!�K�L\343\216r�Kq\210\344�G!c)r�Kq\210\345\346\211�L\346\347%\210,�M\350\351\f\"�M\352�I�C�J
\353�D&��N\306  \354\"�(\306    \355\"�O�P\203\375�\350\356r
q\210\357 )\"\210�N\347=\203
\350\360�(\"\210\202��\361\362 
\"\210\330\363\f�O#\210�J\203$�\364�J!\210
\203,�\313
!\210\n\203A�\365�Q\\�Q\366�R\n�S#)\202M�\367�S!\205M��S�R!.�\202\311�\332\370�\"\210�B\203`�\371\202a�\372�I\346�T\352�I\f
�C�D%�U\373\374 \"\210\375�U\376�V#\210\375�U\377�R#\210\375�U\201W��S#\210\375�U\201X�\n#\210�G\203\261�\201Y��U\344�G!\"\210\201Z��U!\210\201[��U\201\\\"\210�A\205\310�\201]��U�A\"+.
\207\367�S!\205\330��S�R!\207" [commands c next cdir cname cbuf plist-get :default-directory :command-name :buffer-name get-buffer kill-buffer :process-filter :shell el-get-shell-quote-program :program mapcar el-get-maybe-shell-quote-argument :args el-get-plist-get-with-default :sync :stdin file-name-as-directory expand-file-name error "el-get: :program argument cannot be nil" el-get-verbose-message "Running commands synchronously: %S" call-process-shell-command call-process make-temp-file "el-get" get-buffer-create generate-new-buffer-name " *temp file*" ((byte-code "\301�!\203\n\302�!\210\301\207" [temp-buffer buffer-name kill-buffer] 2)) el-get-print-to-string write-region nil 0 message "el-get is waiting for %S to complete" apply t :message :error "%S" buffer-string "el-get: %s" set-window-buffer ...] 8)
  el-get-start-process-list(haskell-mode ((:command-name "*git clone haskell-mode*" :buffer-name "*git clone haskell-mode*" :default-directory "/home/netsu/.emacs.d/el-get" :program "/nix/var/nix/profiles/default/bin/git" :args ("--no-pager" "clone" "--depth" "1" "https://github.com/haskell/haskell-mode.git" "haskell-mode") :message "Package haskell-mode installed." :error "Could not install package haskell-mode.") nil (:command-name "*git submodule update*" :buffer-name "*git clone haskell-mode*" :default-directory "/home/netsu/.emacs.d/el-get/haskell-mode/" :program "/nix/var/nix/profiles/default/bin/git" :args ("--no-pager" "submodule" "update" "--init" "--recursive") :message "git submodule update ok" :error "Could not update git submodules")) el-get-post-install)
  el-get-git-clone(haskell-mode "https://github.com/haskell/haskell-mode.git" el-get-post-install)
  el-get-github-clone(haskell-mode nil el-get-post-install)
  el-get-do-install(haskell-mode)
  el-get-init-and-install((f s dash xclip xterm-keybinder myrth-theme emacs-jabber sx know-your-http-well jquery-doc flymd magit git-gutter+ git-gutter-fringe+ helm-ls-git helm-git-grep git-timemachine smartparens smart-newline anzu auto-indent-mode clean-aindent col-highlight highline lacarte pp-c-l textmate undo-tree whole-line-or-region yasnippet yasnippets helm auto-complete ac-capf goto-last-change phi-search highlight-indentation helm-c-yasnippet helm-descbinds helm-cmd-t helm-swoop helm-ispell helm-ag helm-ack smooth-scrolling inertial-scroll jump-char projectile helm-projectile ag ...))
  el-get(sync (f s dash xclip xterm-keybinder myrth-theme emacs-jabber sx know-your-http-well jquery-doc flymd magit git-gutter+ git-gutter-fringe+ helm-ls-git helm-git-grep git-timemachine smartparens smart-newline anzu auto-indent-mode clean-aindent col-highlight highline lacarte pp-c-l textmate undo-tree whole-line-or-region yasnippet yasnippets helm auto-complete ac-capf goto-last-change phi-search highlight-indentation helm-c-yasnippet helm-descbinds helm-cmd-t helm-swoop helm-ispell helm-ag helm-ack smooth-scrolling inertial-scroll jump-char projectile helm-projectile ag ...))
  (let ((emacs-lisp-mode-hook nil) (el-get-git-shallow-clone t) (el-get-user-package-directory (concat (file-name-as-directory user-emacs-directory) "inits"))) (el-get (quote sync) el-get-packages))
  el-get-sync()
  (progn (el-get-sync) (el-get-clean))
  (if (require (quote el-get) nil (quote noerror)) (progn (el-get-sync) (el-get-clean)) (save-current-buffer (set-buffer (url-retrieve-synchronously "https://raw.github.com/dimitri/el-get/master/el-get-install.el")) (let (el-get-master-branch el-get-install-skip-emacswiki-recipes) (goto-char (point-max)) (eval-print-last-sexp))))
  eval-buffer(#<buffer  *load*-88152> nil "/home/netsu/.emacs.d/site-lisp/getelget.el" nil t)  ; Reading at buffer position 2565
  load-with-code-conversion("/home/netsu/.emacs.d/site-lisp/getelget.el" "/home/netsu/.emacs.d/site-lisp/getelget.el" nil t)
  require(getelget)
  eval-buffer(#<buffer  *load*-999585> nil "/home/netsu/.emacs.d/site-lisp/plugins.el" nil t)  ; Reading at buffer position 13239
  load-with-code-conversion("/home/netsu/.emacs.d/site-lisp/plugins.el" "/home/netsu/.emacs.d/site-lisp/plugins.el" nil t)
  require(plugins)
  eval-buffer(#<buffer  *load*> nil "/home/netsu/.emacs.d/init.el" nil t)  ; Reading at buffer position 726
  load-with-code-conversion("/home/netsu/.emacs.d/init.el" "/home/netsu/.emacs.d/init.el" t t)
  load("/home/netsu/.emacs.d/init" t t)
  #[0 "�\205\262�   \306=\203��\307�\310Q\202;� \311=\204��\307�\312Q\202;�\313\307\314\315#\203*�\316\202;�\313\307\314\317#\203:�\320\nB�\321\202;�\316\322�\323�\322\211#\210�\322=\203a�\324\325\326\307�\327Q!\"\323�\322\211#\210�\322=\203`���\210�\203\243�\330�!\331\232\203\243�\332�!\211\333P\334�!\203}�\211\202\210�\334�!\203\207��\202\210�\314\262��\203\241�\335��\"\203\237�\336\337��#\210\340\341!\210��\266�\f?\205\260�\314�\323\342\322\211#)\262�\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" (initialization "`_emacs' init file is deprecated, please use `.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
  command-line()
  normal-top-level()

@Pitometsu
Copy link
Author

haskell-mode.el:1171:1:Error: the function `haskell-mode-stylish-buffer' is not known to be defined.

@Pitometsu
Copy link
Author

You should put haskell-mode.el after haskell-commands.el. It will fix error.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

I'm not really familiar with Makefile format, so here pretty hardcoded quick dirty fix:

# FIX: byte-compile haskell-mode.el after all
ELFILES := $(filter-out haskell-mode.el,$(ELFILES))
ELFILES += haskell-mode.el

@Pitometsu
Copy link
Author

@fice-t thanks, now multiline really works fine :D however I have been forced to fork repository to be able to install it.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

Okay, I see: there's haskell-interactive-prompt and haskell-interactive-prompt2 variables. Could I use, for example, my funnyprint library to make colorful prompt here?

Like

:set prompt FunnyPrint.prompt "λ " "%s" " ¬\nλ > "
:set prompt2 FunnyPrint.prompt2 "λ" "" " | "

I see, with (setq haskell-interactive-mode-eval-mode 'haskell-mode) (thank you, @fice-t ) I don't need hscolours anymore (it even break things). But I still miss proper indentation for printing results. In FunnyPrint.funnyPrint I have use ipprint library for that. Could I setup Interactive-Haskell mode to use something like that (maybe,stylish-haskell or one of haskell-mode built-in indentations)?


Oh, and I miss proper UTF8 output in strings. E.g. in my funnyPrint I have:

Prelude> let
Prelude|   a = ["Привет","мир", "!"]
Prelude| 
a :: Data.String.IsString t => [t]
(0.00 secs, 0 bytes)
Prelude> a
["\1055\1088\1080\1074\1077\1090","\1084\1080\1088","!"]
it :: Data.String.IsString t => [t]
(0.00 secs, 0 bytes)
Prelude> :color 
λ Prelude ¬
λ > let
λ |   a = ["Привет","мир", "!"]
λ | 
a :: Data.String.IsString t => [t]
(0.00 secs, 0 bytes)
λ Prelude ¬
λ > a
    ["Привет", "мир", "!"]
it :: Data.String.IsString t => [t]
(0.00 secs, 0 bytes)
λ Prelude ¬
λ > 

@fice-t
Copy link
Contributor

fice-t commented Jun 4, 2016

About the errors, that makes sense as byte compiler warnings are set to give make errors. A couple warnings can be fixed, and a couple of them are actually Emacs bugs (that are fixed in Emacs 25). I haven't used el-get so I don't know what it does when the makefile errors.

About funnyprint, I don't think that's possible with the current architecture. It currently sends :set prompt "\\4" (char value 4) to GHCi and uses that as an easy way to detect the prompt. Then it outputs a new haskell-interactive-prompt at an Emacs Lisp level. prompt2 is set at the GHCi level using the value of haskell-interactive-prompt2, but is coloured at the Emacs Lisp level.

Can you see if commenting out the 2 lines containing 'font-lock-face in haskell-interactive-mode-eval-result allows your funnyprint to get a colourful prompt2?

About UTF-8, I think that's just a GHCi problem with show. For instance, if you mapM_ putStrLn a it outputs in UTF-8. Can you see if using funnyprint without the prompt magic works in presenting UTF-8 characters?

About ipprint or stylish-haskell, I think that could be done.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

There's not only warnings, but error in Makefile. Yes, el-get try to make all first. So, because haskell-mode.el depend on other modules, it should be byte-compiled after all. Not sure, is it emacs 24 issue. Anyway, currently, order matter. Right solution will be check and byte-compile depended files after.

@fice-t I can enable both, prompt and prompt2, from funnyprint, and it became colorfut, but, according to "\\4" hacky solution, it break all the things in haskell-mode.

About UTF: in funnyprint I :set -interactive-print=FunnyPrint.funnyPrint which override show action and escape characters in proper way (see here con function). I'm sure, same behavior may be implemented in pure elisp as well.

@Pitometsu
Copy link
Author

@fice-t ok, according to your explanation, I put "\\4" at the end of my prompt for funnyPrint.
And, first of all, it fix crashes, both haskell-doc tips and interactive-haskell navigation.

But see, what I currently have:

Screenshot

@Pitometsu
Copy link
Author

I mean:

  • escape codes in prompt
  • part of prompt in haskell-doc tips
  • "\\4" rendered as prompt by elisp

However, all of that expected.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

Feature requests:

  • let me use my own prompt (I can set something like "\\3" at the begin and "\\4" at the end of it
  • UTF support (well, here I can just setup function in GHCi by my own)
  • indentation (here probably better solution will be use something from haskell-mode

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

Oh, by the way, I shouldn't set "\\3" and "\\4" by hand. Because I need proper prompt in plain shell as well. So nicest solution will be: add "\\3" at the begin of prompt and "\\4" at the end of prompt in elisp at haskell-mode.

@fice-t
Copy link
Contributor

fice-t commented Jun 4, 2016

So the escape codes only appear on the first prompt after :color?

"\4" rendered as prompt by elisp

Can you eval the below (after everything is loaded) and see if this helps? It's just a new unless check.

(setq haskell-dont-show-prompt t)
(defun haskell-interactive-mode-prompt (&optional session)
  "Show a prompt at the end of the REPL buffer.
If SESSION is non-nil, use the REPL buffer associated with
SESSION, otherwise operate on the current buffer."
  (with-current-buffer (if session
                           (haskell-session-interactive-buffer session)
                         (current-buffer))
    (goto-char (point-max))
    (unless haskell-dont-show-prompt
      (let ((prompt (propertize haskell-interactive-prompt
                                'font-lock-face 'haskell-interactive-face-prompt
                                'prompt t
                                'read-only t
                                'rear-nonsticky t)))
        ;; At the time of writing, front-stickying the first char gives an error
        ;; Has unfortunate side-effect of being able to insert before the prompt
        (insert (substring prompt 0 1)
                (propertize (substring prompt 1)
                            'front-sticky t))))
    (let ((marker (setq-local haskell-interactive-mode-prompt-start (make-marker))))
      (set-marker marker (point)))
    (when haskell-interactive-mode-scroll-to-bottom
      (haskell-interactive-mode-scroll-to-bottom))))

part of prompt in haskell-doc tips

Most likely because haskell-doc expects the regular prompt. I'm not sure how much life haskell-doc has left, so maybe when someone rewrites it the situation there will be better.

UTF support (well, here I can just setup function in GHCi by my own)

Does just :set -interactive-print=FunnyPrint.funnyPrint work for you now? I don't think it can really be supported out of the box unless GHCi itself supports it out of the box.

@Pitometsu
Copy link
Author

Does just :set -interactive-print=FunnyPrint.funnyPrint work for you now? I don't think it can really be supported out of the box unless GHCi itself supports it out of the box.

Yes, but if I enable colors in elisp (setq haskell-interactive-mode-eval-mode 'haskell-mode) it show me a lot of additional escape codes (that's ok and expected, because I colorize output in that function too). But UTF anyway looks normal.
So here comparison of output in haskell-interactive and ansi-term

Screenshot

^D in ansi-term because of "\\4" (haskell-mode will crash my emacs without it).

@fice-t
Copy link
Contributor

fice-t commented Jun 4, 2016

because I colorize output in that function too

Does it do all of your colouring, or do you get additional colours with haskell-mode's font-lock?

Anyway, try this and see if it helps:

(defun haskell-interactive-mode-eval-as-mode (session text)
  "Insert TEXT font-locked according to `haskell-interactive-mode-eval-mode'."
  (with-current-buffer (haskell-session-interactive-buffer session)
    (let ((inhibit-read-only t))
      (delete-region (1+ haskell-interactive-mode-prompt-start) (point))
      (goto-char (point-max))
      (let ((start (point)))
        (insert (ansi-color-apply (haskell-fontify-as-mode text
                                         haskell-interactive-mode-eval-mode)))
        (when haskell-interactive-mode-collapse
          (haskell-collapse start (point)))))))

^D in ansi-term because of "\4" (haskell-mode will crash my emacs without it).

Did you try the code snippet in my last post? If that works for you in Interactive-Haskell then I can think of an easy enough workaround.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

Can you eval the below (after everything is loaded) and see if this helps? It's just a new unless check.

If I firstly run this code, than start haskell-interactive, it just don't work.

Screenshot

But if I firstly start haskell-interactive session and then run your code snippet, it partially works (here without FunnyPrint.funnyPrint, only with my prompts). But RET and history navigation seems broken:

Screenshot

UPD: you see :color where I enable my prompt.
UPD: once prompt after two prompt2 worked properly here. Maybe, conflict with (setq haskell-interactive-mode-eval-mode 'haskell-mode) a little.

@Pitometsu
Copy link
Author

@fice-t ,

Anyway, try this and see if it helps:

Screenshot

Looks much better, but RET and history navigation still broken.

@fice-t
Copy link
Contributor

fice-t commented Jun 4, 2016

If I firstly run this code, than start haskell-interactive, it just don't work.

Yes, I saw that. It's an easy fix I can do if this all works out.

RET and history navigation works for me with just :set prompt "λ %s ¬\nλ > �". Don't use the \\4 directly in ghci. You can input the proper character in Emacs with C-q C-d.

Also see if it works with a non-empty input.

Though things like C-c C-p and the like are broken with a different prompt and would need a bit of work to fix.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 4, 2016

@fice-t many thanks for your attention to this small feature. I'll be really enjoyable if it will be implemented.

@geraldus
Copy link
Contributor

geraldus commented Jun 5, 2016

I like colorful output too (:

@fice-t
Copy link
Contributor

fice-t commented Jun 5, 2016

I've gotten mostly everything, but I can't find an easy way to get the value of the user's prompt from GHCi. Is there a way to bind the output of ":show"? Parsing the result on the Emacs side before everything is set up doesn't seem to work.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 6, 2016

@fice-t I see at least 2 workarounds:

  • let ghci put prompt in another buffer, change it, if necessary, here (like add "\\4"), then copy output in buffer with current session (emacs lisp with-current-buffer)
  • let user customize some elisp variable to set GHCi function (like :def setupprompt (\_ -> return (":set -package funnyprint\n:set prompt \"" ++ FunnyPrint.prompt "λ " "%s" " ¬\\nλ > \\4" ++ "\"" ++ "\n:set prompt2 \"" ++ FunnyPrint.prompt2 "λ" "" " | " ++ "\""))) with desired prompt specially for haskell-mode, then use :setupprompt on load GHCi.

@Pitometsu
Copy link
Author

@fice-t in GHCi :show prompt and :show prompt2.

@Pitometsu
Copy link
Author

@fice-t oh, I misunderstood the question. Hm, what about deal with haskell-interactive session buffer just let GHCi print with save-excursion?

@Pitometsu
Copy link
Author

Pitometsu commented Jun 6, 2016

ghci -ghci-script <<< `echo :show prompt`

not works like expected :(

@Pitometsu
Copy link
Author

@fice-t or you can try handle it just with markers (not really good solution for compatibility with plain shell) like "\\3prompt\\4".

@Pitometsu
Copy link
Author

Pitometsu commented Jun 6, 2016

I got another compatibiliti issue with (setq haskell-interactive-mode-eval-mode 'haskell-mode)
e.g. I have :def! search return . (":!hoogle --count=50 --color ")

λ > :search state
Searching for: [0;1mstate[0m
Control.Monad.Trans.State.Lazy [0;1m[0;1;4mstate[0;1m[0m :: (Monad m) => (s -> (a, s)) -> StateT s m a
Control.Monad.Trans.State.Strict [0;1m[0;1;4mstate[0;1m[0m :: (Monad m) => (s -> (a, s)) -> StateT s m a
Control.Monad.Trans.RWS.Lazy [0;1m[0;1;4mstate[0;1m[0m :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a
Control.Monad.Trans.RWS.Strict [0;1m[0;1;4mstate[0;1m[0m :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a
Control.Monad.State.Class [0;1m[0;1;4mstate[0;1m[0m :: MonadState s m => (s -> (a, s)) -> m a
Control.Monad.State.Lazy [0;1m[0;1;4mstate[0;1m[0m :: MonadState s m => (s -> (a, s)) -> m a
Control.Monad.State.Strict [0;1m[0;1;4mstate[0;1m[0m :: MonadState s m => (s -> (a, s)) -> m a

@fice-t
Copy link
Contributor

fice-t commented Jun 6, 2016

let ghci put prompt in another buffer, change it, if necessary, here (like add "\4"), then copy output in buffer with current session (emacs lisp with-current-buffer)

The issue I'm having is that the process hangs when I attempt to get any information from the process before changing prompt.

let user customize some elisp variable to set GHCi function ... with desired prompt specially for haskell-mode, then use :setupprompt on load GHCi.

This is actually what I got working yesterday, but I felt that it would be best to use whatever users have in their .ghci instead of having another variable to configure. If this doesn't matter to you then I could just put up a PR for you to test.

or you can try handle it just with markers (not really good solution for compatibility with plain shell) like "\3prompt\4".

The issue is that I can't change prompt without losing the old value. Some built-in way to append to the prompt is all that I need, but GHCi doesn't seem to want me to do that easily.

@Pitometsu
Copy link
Author

Pitometsu commented Jun 6, 2016

The issue I'm having is that the process hangs when I attempt to get any information from the process before changing prompt.

Oh, I have same without "\\4" at the end. Something haskell-mode specific.

Try turn of e.g. haskell-doc to elaborate this, maybe...

@Pitometsu
Copy link
Author

Pitometsu commented Jun 6, 2016

@fice-t Anyway, properly color prompt may be configured only by code (because depend on terminfo, which different e.g. in emacs and xterm). So, anyway for now in GHCi user must use it through :def setupprompt (\_ ->":set prompt " ++ bla-bla-prompt-compute-and-setup). So, I propose run GHCi with "\\4" prompt with no output in buffer, then call :setupprompt, then :show prompt, get output and setup new prompt for GHCi via emacs lisp. :setupprompt function name may be customizable.

@Pitometsu
Copy link
Author

But if user don't have colored prompt, just predefined, e.g. 2-lined (with \n), then yes, it will be useful to be able to read this...
Also there's a case if user will change prompt during session.

@fice-t
Copy link
Contributor

fice-t commented Jun 6, 2016

:setupprompt function name may be customizable.

If there was going to be a variable needed to customize the prompt, then it could just use haskell-interactive-prompt directly, I think. See #1357.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants