haskell / haskell-mode Goto Github PK
View Code? Open in Web Editor NEWEmacs mode for Haskell
Home Page: http://haskell.github.io/haskell-mode/
License: GNU General Public License v3.0
Emacs mode for Haskell
Home Page: http://haskell.github.io/haskell-mode/
License: GNU General Public License v3.0
It would be nice to have a function that would completely destroy the currently active/loaded session on screen, removing all evidence of it ever having existed. If user tries to F5 on any of the previously associated files, a completely new session should start with a question asking for the cabal directory.
This would be particularly convenient when Emacs is loaded for extended periods of time - as it usually is - and the user wants to cleanly shut down (and perhaps later decide to restart) unattended Haskell sessions.
Please note that when the session is to be restarted, the process should really start from scratch and ask once again the cabal file and the working directory.
Is it currently possible to point a project/session to a cabal-dev directory that is different to that which contains the project.cabal file? (And is it even a good idea to do this)
I'm hacking on a project (distributed-process) which contains multiple dependent projects in the same tree:
tree -L 1 ..
..
├── benchmarks
├── cabal-dev
├── distributed-process
├── doc
├── examples
├── install_all.sh
├── network-transport
├── network-transport-pipes
├── network-transport-zmq
└── README.md
My project is network-transport-zmq which contains the .cabal file but I'd like to use the cabal-dev in the parent directory.
I tried emacs --load examples/init.el
and everything works, except for one thing: when I hit TAB on an error message in the interactive buffer, it just inserts a tab. Even though the keymap is getting loaded, it looks like tab is still only bound to (indent-for-tab-command). Everything else works fine as far as I can tell.
I'm using GNU Emacs 23.3.1 in a terminal emulator (over ssh) in case that matters.
Hello,
I have been using haskell-mode with emacs 23.* for quite some time. Great work!
Recently, I have upgraded emacs to version 24.1.1 and compilation error jumps seem to have stopped working.
For example, you're working on a haskell file, you do C-c C-l to load that file, and compilation errors (if any) will appear in the compilation buffer.
In emacs 23.*, you could hit RET on those compilation errors to jump to the appropriate file location.
This does not seem to work anymore.
If you need any more information, please let me know!
Cheers,
José
When I'm working on a project, and most typically, I add a module dependency to the cabal file, what's the correct way to reload the repl? I've been trying haskell-interactive-restart
, as you might expect, but what I get instead is a disconnected repl, and this
when I quit.
What's the 'right way' to do it? :)
I need to pass command line arguments to ghci to load shared lib: -Llib -lpdf
it would be great to setup ghci arguments per project.
Unfortunately i cannot set them up via .ghci file. For some reason they do not work like that. Only from command line.
I have run into the following problematic scenario a number of times:
(No changes need to be saved) [2 times]
Start a new project named “myapp”? (y or n) y
setf: Wrong type argument: consp, nil [2 times]
I'd like to see haskell-mode support better integration with the ghci debugger -- mode key bindings for stepping, tracing, printing, etc, and highlighting of the current source location in the source buffer.
Hello.
When writing something like:
bleh, bluh ∷ Blah
[bleh,bluh] = map blahfication [e,u]
blih :: Blah
bleh and bluh appeir in normal font-face in haskell mode, while one would expect them to appeair highlighted like blih is. The "comma-separated multiple type signature" case should definetely be highlighted. I admit that the "pattern matching at top-level" is more tricky…
Subject: haskell jumping working directory to parent on exit
From: Per Fredelius [email protected]
To: [email protected]
I have the following issue: If I do this:
Then ghci will give me an error, the module can not be found. Using
getCurrentDirectory (in System.Directory) will tell me why. Current
directory has been switched from previous session. It is now in the
previous directories parent directory. So if my testmodule has path
parentfolder/myfolder/Test/Test.hs the working directory will become
parentfolder/myfolder the first time and parentfolder the second time.
If I do close the buffer in between sessions the issue does not occur.
A friend suggested that haskell mode will look for cabal files and
sometimes change directory to one having one. I've tried moving my
cabal file around to no avail.
I'm still an emacs newbie so I may have confused some things up. I'm
not sure what happens, only the end result. This issue is mainly an
actual issue for me because of modules that cause ghci to crash when
closing them because of 'misbehaving' non-haskell dependencies
(opengl). Debugging would be much less of a hassle if I can trust in
C-c C-l.
Thanks in advance
forwarding http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343248
Daniel Burrows writes:
haskell-mode indents parallel list comprehensions (the GHC extension)
just fine, but it seems to have trouble with non-parallel ones. For
instance, consider this code fragment:
allCards :: CardUniverse -> [CardValue]
allCards (CardUniverse s free) = free ++ suited
where suited = [cv | suit <- s,
(cv, _) <- elems (suitCards suit)]
haskell-mode wants me to indent the last line to either the level of
"s" or the level of "cv" in the previous line; for instance:
-- | Returns a list of all the cards in the universe; this will be a
-- set if the universe is well-formed.
allCards :: CardUniverse -> [CardValue]
allCards (CardUniverse s free) = free ++ suited
where suited = [cv | suit <- s,
(cv, _) <- elems (suitCards suit)]
I verified that this behaviour still exists with 2.8.0 and turn-on-haskell-indentation
My haskell-mode.el says haskell-version is "$NAME: $".
I couldn't get version number.
When emacs comes up I can't invoke (via key mappings of course) haskell-process-bring or haskell-process-load-file without moving around in the file first. Not a big issue but disconcerting for a new user.
In REPL prompt is set to 'λ>' by default and when I enter some text and press 'Home' cursor goes just before the lambda so user needs to 3 times 'left' to get to the input first character
In Interactive-Haskell mode, default key bindings for previous commands would be nice. I use Alt-up and Alt-dn. Can do a pul request if you prefer.
Is there a reason why haskell-mode is derived from fundamental-mode rather than prog-mode?
haskell-process-do-type adds parenthesis around alpha-numeric names and inserts them when used with a prefix argument.
For example it will insert the type signature
(foo) :: t -> t
for the function
foo x = x
I'll make this ticket once and I won't complain about it again. Some points:
That's all. If you don't agree I don't care to argue the case, more interested in hacking, just thought I'd try.
I need to make the input grabbing code a bit smarter, as it currently supports multi-line input, so I will use some text-properties or markers to determine boundaries.
in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570236
Marco Túlio Gontijo e Silva writes:
If I have a big line, like:
If set to yes then the package management system will refuse to remove the package (upgrading and replacing it is still possible). The other possible value is no, which is the same as not having the field at all.$
And I press at the end of the line, I get:
If set to yes then the package management system will refuse to remove the $
package (upgrading and replacing it is still possible). The other possible value is no, which is the same as not having the field at all. $
Where I wanted:
If set to yes then the package management system will refuse to remove the
package (upgrading and replacing it is still possible). The other possible
value is no, which is the same as not having the field at all.
(I've added a $ in the end of the lines).
This is with turn-on-haskell-indentation in 2.8.0
When I load a cabal file and hit C-c C-c to build the cabal project, my screen is split vertically just as it gets split when I use the standard Emacs M-x compile command.
However, when the compile fails and I hit enter on the error message in the interactive shell, the screen gets split horizontally. This happens even when I already have .hs file and the interactive windows both open in a vertical split configuration.
I think the problem is in haskell-interactive-bring. I see that it splits windows horizontally.
However, it seems to me that the code actually tries to avoid splitting in case the current window configuration is already split such that there's a source file and an interactive window already active. I think the find-if search somehow fails to detect this configuration.
So two things: 1) correctly detect the window configuration and don't split if the config is already ok and 2) split vertically if a split needs to be done.
PS. The new interactive stuff w/ cabal-dev is great! I've been looking for this for quite some time.
;;;###autoload
(defun haskell-interactive-bring ()
"Bring up the interactive mode for this session."
(interactive)
(let ((session (haskell-session)))
(let ((buffer (haskell-session-interactive-buffer session)))
(unless (and (find-if (lambda (window) (equal (window-buffer window) buffer))
(window-list))
(= 2 (length (window-list))))
(delete-other-windows)
(split-window-horizontally)
(switch-to-buffer-other-window buffer)
(other-window 1)))))
Edit: More specific repro steps:
I'm trying to debug the Elisp code to understand why this happens.
I open a haskell project with a cabal file and use the f5 bind supplied in the examples dir. A prompt asks me to start a new project and so on. I do this and everything is working as expected, but on restarting emacs I have go through this prompt process again.
I'm using Windows 8 with Emacs 24 and the latest haskell-mode.
When I hit f5
in a Haskell buffer I get this output:
BrainzStem/Database.hs:30:8: Ambiguous module name `Control.Monad.CatchIO': …
The project cabal file only depends on package that provides this module, however. I am using ghci, not cabal-dev.
This might just be my incompetence in configuring emacs but for some reason new lines opened after an import statement (e.g. to insert another import) begin as indented, generally aligned to the beginning of the module name of the previous line. It's unclear why this happens as your configuration (as seen in your Youtube tutorial) doesn't seem to do this. I am using the simple indentation method as seen in your init.el,
(defun haskell-hook ()
;; Use simple indentation.
(turn-on-haskell-simple-indent)
(define-key haskell-mode-map (kbd "<return>") 'haskell-simple-indent-newline-same-col)
(define-key haskell-mode-map (kbd "C-<return>") 'haskell-simple-indent-newline-indent)
)
QuickCheck uses backspace characters to make nice output while it is running tests. This does not work in haskell-interactive-mode:
λ> import Test.QuickCheck
λ> quickCheck (\xs -> reverse (reverse xs) == xs)
(0 tests)���������^H^H^H^H^H^H^H^H^H ���������^H^H^H^H^H^H^H^H^H(1 test) [etc.]
I think the old inferior-haskell mode handles this properly, but I'm not sure how to fix it in the new interactive mode.
(format ":!cd %s && %s | %s | %s"
(haskell-session-cabal-dir (haskell-process-session (car state)))
"find . -name '*.hs*'"
"grep -v '#'" ; To avoid Emacs back-up files. Yeah.
"xargs hasktags -e -x")))
I think you'd have to find another way to do that; grep, find, xargs aren't on windows--you might be able to use powershell commands instead.
ETA: This might help.
ETA2: The necessary powershell command is hasktags -e -x (ls -fi *.hs -exclude "#*" -name -r)
. I don't know elisp or how :!cd
works, but from powershell you'd need to do cd %s ; %s
When I hit 'enter' on lines other than the line with prompt I get some errors and in history I get some strange multiline block after showing which history toggling stops working (looks like it has something to do with newlines in history element)
And If I have in buffer:
λ> '1'
'1'
λ>
And press 'enter' on the 2nd line I get -
haskell-interactive-mode-input: Args out of range: "
", 3, 2
I get a parser error when using → in a lambda expression.
haskell-process-cabal-build
does show compilation errors, but when using haskell-process-load-file
I only get a message showing "Compilation failed" in the REPL. The errors are, however, shown in the haskell-process-log
buffer. This is on Windows.
This example
help _ _ _ = putStrLn $
" wheel up --> next image\n\
\ up arrow --> next image\n\
\ wheel dn --> prev image\n\
\ r arrow --> next field\n\
\ l arrow --> prev field\n\
\ \"x\" --> del format\n\
\ \"f\" --> new format\n\
\ \"n\" --> new field\n\
\ \"d\" --> del field\n\
\ 1-5 --> set field name\n\
\ click --> set upper left\n\
\ r-click --> set lower right\n\
\ ctl-click --> set lower right\n\
\ w --> write file\n\
\ p --> print file to screen"
yields the error
lisp-nesting exceeds `max-lisp-eval-depth'
To be fair it breaks the old haskell mode too, so feel kick it into touch.
in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570243
Marco Túlio Gontijo e Silva writes
If I have a line like:
Data D = A | B$
With a cursor right after A, and I press , I get:
Data D = A $
| B$
When I expected to get:
Data D = A$
| B$
(I included a $ in the end of the line.)
[edit by bremner; fix markup to more clearly show expected results]
Playing around I used putStr to output some string variable and it happens that when you do it REPL gets broken. Looks like it has something to do with prompt staying on the same line as the last line of output.
Some indentation modes can reasonably go backward in the indentation, not only forward. This variable allows those indentation modes to support this backwards indentation generically in the same way they do with `indent-line-function'.
Here is a commit for that variable and a useful implementation for haskell-simple-indent.el.
I've tried to run "haskell-process-load-file" and after answering some questions about starting a new project and current directory got a message "Invalid function: setf".
I wanted to use a new haskell-interactive-mode instead of inferior-haskell-mode, since the latter does not play very well with GHC 7.4.1: it is not possible to move between compilation errors, presumably because the messages format have been changed and old hardcoded regexes do not match anymore.
But alas, I am unable to run haskell-interactive-mode at all.
Because there's no default indentation mode (kinda weird but), it'd be nice to bring up the documentation for the indentation modes when the user first tries to indent.
I popped some docs based on the existing docs with a bit more help, into the docstring of an Elisp variable, then based on that you can bring up the describe-variable buffer by default.
Seems like it's helpful to the newbies to Emacs and even the advanced users wouldn't mind. :-)
I can only make one merge request at a time so here's a ticket with some commit references.
I've found that cabal-mode for some reason insists on indenting with tabs, causing Cabal to complain. I'm a recently converted vim user, so it may be that there is nothing that can be done about this in haskell-mode. If this can't be fixed in haskell-mode, what is the recommended way to configure emacs to use spaces instead of tabs in cabal-mode?
I got the following error calling 'haskell-process-load-file:
Related.hs:14:18: Could not find module `Data.ByteString.Lazy': …
It is a member of the hidden package `bytestring-0.9.1.10'.
Perhaps you need to add `bytestring' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
Compilation failed.
I added the dependency to the .cabal file as suggested. Then,
Opening a new emacs instance and Related.hs, doing 'haskell-process-cabal-build, loads the file as expected.
I've pulled recent version from github, run make compile and when loading new project (I'm using new interactive mode) I get haskell-session-set: Invalid function: setf
in messages buffer and project could not be loaded.
I use GNU Emacs 23.2.1 on Ubuntu Natty
Currently I've added (require 'cl)
to haskell-session.el and it works but I have little elisp experience so I'm not sure that it's the proper solution for this problem.
When "starting a new project", the process window starts and grabs the focus, preventing me from answering the next question without touching the mouse (horrors!) to click on the dialog area at the bottom.
Also I think I should be "starting a session" or "loading a project", versus the current "starting a session".
Cheers.-T
An useful addition to haskell-mode would be https://github.com/roelvandijk/emacs-haskell-unicode-input-method by @roelvandijk
It should be made a bit more configurable (e.g. via the customize interface) though, in order to customize the degree of "unicodification" wanted, and/or maybe detect the presence of the UnicodeSyntax
language extension pragma and module-imports (of the *.Unicode modules) to enable/disable unicode symbol groups on a per-file basis.
It might be beneficial for some user setups to get Emacs compiler error system working with haskell-interactive-mode errors.
As an example, here is what I have in my global config file:
(global-set-key (kbd "C-,") 'previous-error)
(global-set-key (kbd "C-.") 'next-error)
These commands also work for grep and occur results and easy to reach keys such as these make it very easy to navigate the them.
Additionally, it would be good to have these commands work from within the Haskell files (and not necessarily exclusively inside the interactive session). With that, the user workflow would be:
without a need to even touch the ghci session in between.
The titled message pops up in an annoying buffer when Emacs starts. It is due to this code:
(eval-when-compile
;; Emacs 21 defines `values' as a (run-time) alias for list.
;; Don't maerge this with the pervious clause.
(if (string-match "values"
(pp (byte-compile (lambda () (values t)))))
(defsubst values (&rest values)
values)))
Should the regex "^module[ \t]+([^- \t\n]+.[^- \t\n]+)[ \t]+" in inf-haskell.el should match whitespace before "(".
module Blah.Blah ( blah
) where
matches "Blah.Blah", but
module Blah.Blah( blah
) where
matches "Blah.Blah("
On my GHC 7.0.4 system 'C-c C-d take' takes me to
http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC-List.html#v:take (unavailable)
instead to
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take
Am I using the wrong GHC version?
I tried to use the C-c C-d command to pop up the documentation for the function randomRIO
, but unfortunately Emacs tried to reach it under the following (incorrect) URL:
http://www.haskell.org/ghc/docs/latest/html/libraries//%60System-Random%27.html#v:randomRIO
It looks like haskell-mode doesn't parse the output from ghc-pkg
correctly? Is that maybe because I'm using ghc 7.4.1?
Antti-Juhani Kaijanaho writes (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=575081)
{- lorem ipsum hgfh yjfgh yjthj ythygjty 6utyfg u6thtyj rhtyh rt46 hty y5rth trfdtrd htr trhr -}
gets rewritten by fill-paragraph (M-q) as
{- lorem ipsum hgfh yjfgh yjthj ythygjty 6utyfg u6thtyj rhtyh rt46 hty
{- y5rth trfdtrd htr trhr -}
This problem is still present for me in 2.8.0 with turn-on-haskell-indentation
When running (haskell-mode-stylish-buffer)
, it doesn't actually run or reformat my buffer. Instead it prints let: Symbol's value as variable is void: haskell-session
to the *Messages*
buffer.
I'd prefer if arrows aligned under the :: in type signatures, like so:
f :: a
-> b
Right now we get
f :: a
-> b
I don't know how much extra time I spend realigning things when coding. Perhaps this could be made an option if everyone can't agree on the style here?
Have I missed a simple way to get tags for all the modules my project depends on? Currently I manually generate them with hasktags and put them in the project tree. I don't bother with Prelude and other basic packages although sometimes I need to look up definitions from those as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.