GithubHelp home page GithubHelp logo

emacs-haskell-tutorial's Introduction

Using Emacs for Haskell development

Join the chat at https://gitter.im/serras/emacs-haskell-tutorial

Emacs is a text editor with an amazing support for extensions. Many people have built add-ons for Emacs to deal with everything from e-mail to version control or agenda planning, but it excels in providing good support for programming. Haskell has actually an amazing support, which integrates highlighting, querying information, building with Cabal and even refactoring!

If you want to know how to set up this awesome environment, follow the tutorial. Later, you can use the Emacs configuration file as a template for your own .emacs.d/init.el or .emacs.

emacs-haskell-tutorial's People

Contributors

aaron-em avatar bmabey avatar christopherking42 avatar conor10 avatar dpkatz avatar emaphis avatar gitter-badger avatar greenrd avatar jyp avatar kini avatar kyakir avatar levinotik avatar massysett avatar patrikja avatar purcell avatar serras avatar sportanova avatar willsewell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emacs-haskell-tutorial's Issues

Searching for program: no such file or directory, ghci

For some reason emacs is not able to find my ghci. I have no idea what the issue is. I am running Ubuntu 16.04, and followed the instructions in this tutorial to the book.

Using which ghci I get the path /opt/ghc/7.10.3/bin/ghci. And executing M-: exec-path and M-: (getenv "PATH") I can see that path correctly printed.

I have tried to explicitly set the PATH variable in emacs like this, which changes nothing since as far as I could tell it was already there.
(setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/opt/cabal/1.22/bin/cabal:/opt/ghc/7.10.3/bin/ghci") (setq exec-path (split-string (getenv "PATH") path-separator)

The same thing happens when I use
(custom-set-variables '(haskell-process-type 'cabal-repl))

I would greatly appreciate help. :) I have no idea what to do, and I haven't found any answers on the internet.

Generation of tags

I'm following along the tutorial. I'm stuck in the section on settings up tags. No TAGS file is being generated when I save.

Related to haskell-mode I have this in my .emacs

(let ((my-cabal-path (expand-file-name "~/.cabal/bin")))
  (setenv "PATH" (concat my-cabal-path path-separator (getenv "PATH")))
  (add-to-list 'exec-path my-cabal-path))

(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)


(custom-set-variables
  '(haskell-tags-on-save t))

If I do M-: (getenv "PATH") then the correct path to .cabal/bin appears. Hasktags is installed and a binary file exists in the Cabal bin directory.

As I mentioned a tags file is not being generated on save. Thus M-. does not work. If however I do haskell-mode-tag-find then a GHCi session is being started and a TAGS file is generated. From then on the TAGS file is also being updated on save.

In the haskell-mode documentation tags appears as belonging to the interactive mode.

I'm unsure if I'm doing something wrong of if the tags part shouldn't have been included in the non interactive part of the tutorial.

Suggestion: don't bind haskell-interactive-bring directly

Note that haskell-interactive-switch is the ideal top-level function for switching to the REPL. But also, once you're in the repl, haskell-interactive-switch-back will return you to the original source file: this was added very recently. Both commands are bound to C-c C-z in the two corresponding modes, so I'd suggest that your rebinding might make things less convenient for users.

C-x O

Great Tutorial.

Can you please include C-x O, that let's the user move between the buffers..

ghc-mod from (m)elpa has to match the cabal ghc-mod

I just discovered that installing ghc-mod from cabal and installing the "ghc" package via package-install is not always a good idea since both might not work together.

I'm using ghc-mod from stackage-lts-2.9, which does not have the "legacy-interactive" command which is used by the "ghc" package from (m)elpa. So ghc-mod doesn't work for me (and, unfortunately, doesn't print a clear error message anywhere).

An alternative would be to use the .el files located in ~/.cabal/share/..., which correspond to the installed ghc-mod version. Maybe this should be advised in the tutorial?

alex or happy?

In the Section "Haskell preliminaries" you talk about installing happy. Then you explain how to do it:

cabal update
cabal install alex

This is a confusion, isn't it?
(To be honest, I am not familiar with the packages, so it perhaps alex includes happy or something)

Company mode

Any idea how ghc-boot process is done? I have tried for nearly three days now to get this to work. Company mode does not seem to work in any given haskell buffer. Everything else works great, but the completions are non existent. Any idea welcome thanks

cabal path in windows

(let ((my-cabal-path (expand-file-name "~/.cabal/bin")))
  (setenv "PATH" (concat my-cabal-path ":" (getenv "PATH")))
  (add-to-list 'exec-path my-cabal-path))

You need change ":" to ";" in Windows.

Cabal hell

As it currently stands, it is impossible to follow this tutorial exactly as written since installing the packages using the current version of ghc in the order given will lead to package conflicts, and cabal will refuse to work. Even installing all packages at once doesn't work on a system I recently tried -- cabal somehow tries to install a very old version of ghc-mod and fails.

It is a bit unfortunate that beginners have to endure these things, but maybe the tutorial should include a section telling the reader what to do when cabal hell is encountered, for example

rm -rf `find ~/.ghc -maxdepth 1 -type d`; rm -rf ~/.cabal/lib; rm -rf ~/.cabal/packages; rm -rf ~/.cabal/share;

Need to mention happy

It is necessary to install happy first otherwise lots of cabal install won't work. Installing happy is only mentioned at the end, when the command for installing everything at once is given.

How to integrate stack?

haskell-mode has support for stack when haskell-process-type is set to stack-ghci. It would be great to cover that stuff in the tutorial. I'd be particularly interested in having a good solution that allows me to switch haskell-mode between cabal and stack projects easily.

Cannot find certain modules

I'm having a strange error where haskell-mode can't seem to find certain modules. My project compiles fine, and haskell-mode interactive can find the modules fine (it may be mod-ghc, but I'm pretty sure it's haskell-mode because M-? doesn't show an error). The weird thing is when I manually run mod-ghc check myfile.hs it also doesn't show an error. The modules are there in my cabal file.

Here is an example of the error message in emacs:

error message

and these are what the errors look like in my imports section:

imports

I have no idea how to debug this...

ghc-init no longer exists in the "ghc" package

Hi, I have been using your tutorial to setup my Haskell env in emacs and I could not find the ghc-init function to run at startup as suggested in the text.

I guess the tutorial needs to be updated to reflect changes in the ghc emacs package?

Martin

C-c C-r is undefined?

Hello,

I've just tried to use the above but there is no keybinding defined for the above? I don't see it defined in the dot-emacs.el either.

Confusing references to ```M-.```

In the Non interactive commands section of the tutorial, there is the following text that seems to be referring to a code sample line that no longer exists (bolding for emphasis is mine):

Then open the personal configuration file and add the following lines:

(setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH")))
(add-to-list 'exec-path "~/.cabal/bin")
(custom-set-variables '(haskell-tags-on-save t))

The first two lines are needed to tell Emacs that it should look for the hasktags program in your Cabal binaries directory, which is not a location it already knows about. The next line is the one enabling hasktags itself. Finally, we bind the M-. key combination to jump to the definition of an element when you are over it.

Note: in order to use the M-. command, your file needs to be in a Cabal project, or haskell-mode will ask to create a temporary one.

Note that there is no "final" line discussing the binding of M-. - it looks like it was removed in an earlier version of the document.

I don't really understand what the current state of the world is for M-. in haskell-mode so I don't have a patch to offer. But speaking as a total newcomer to Haskell who is otherwise finding this tutorial quite useful, this part could use some clarification.

Thanks for this tutorial - it is clearly going to be a superb resource.

Breakets

I am using this tutorial for learning emacs (but did the included Emacs-tut before).
There are some things that are not quite clear in your tutorial. I will write about them in the Issues so you might improve and discuss it:

When you tell me the first time to eval (find-file user-init-file), it might be handy to mention that the brackets are essential.

hi2 docs

Hi,

I have this already on melpa:

https://github.com/errge/hi2
http://melpa.milkbox.net/#/hi2

It fixes some issues of haskell-indentation. There have been talks about merging this back to haskell-indentation, but that's in the future. Since you already have this very nice write up, I wanted to ask if you're willing to add this?

Can you please spend 5 mins trying to set this up for yourself based on the readme? https://github.com/errge/hi2/blob/master/README.md

If you like it, I'm happy to prepare the changes to this documentation as a pull request, I just didn't want to spend too much time on it before asking you if you're willing to merge.

Thanks for taking the time and happy indenting!
Gergely

Controlling the errors/warnings reported by ghc-mod

How do I configure the ghc emacs mode to run ghc-mod with flags of my choosing? I'd like to disable the warnings related to shadowing of bindings.

A google search has failed to point me in the right direction. Once I find out, I'll update this documentation...

Include chrisdone's hindent?

Chris Done wrote a wonderful Haskell pretty-printer called HIndent, which is very easily integrated into Emacs. Would you mind adding it to the tutorial?

Random squiggly underlines on every line

I set up emacs (with emacs prelude installed) in the same way as this tutorial (using the exact configuration file in this git repo). But on every line in Haskell files I get randomly positioned 1 character long squiggly underlines on every line.

Screenshot: Squiggly Lines

Do you know what is causing this?

cabal install happy

capture

I have installed cabal and happy and refreshed the packages with

`

               (require 'package)
               (add-to-list 'package-archives
              '("melpa-stable" . "http://stable.melpa.org/packages/") t)
              (package-initialize)

`

I couldn't get the syntax hightlighted. Am I missing something ?

Melpa vs Stable-Melpa

I just tried to follow this excellent guide to setting up a nice Haskell environment in Emacs.

I couldn't get M-? to work however I got the following error

ghc-display-with-name: Symbol's function definition is void: turn-off-haskell-font-lock 

I also got the same warning when installing the ghc package in Emacs.

From the ghc-mod github page it seems quite clear that they mainly support using stable-melpa.

Switching package repositories fixed my problem so it might be the right fix.

I am however very much an Emacs rookie so I might be going about it all wrong.

Maybe the guide should use stable-melpa?

cabal install happy

I have installed cabal and when I follow the instructions I am blocked by this. Do I have to install Ghc ?

D:\Downloads>cabal update
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

D:\Downloads>cabal install happy
cabal: The program ghc version >=6.4 is required but it could not be found.

void variable exedir=

I installed Emacs 24.4.90.2 with an empty .emacs.d (only the init.el from this tutorial), and installed haskell-mode. A lot of things work well, including opening a REPL, but when I try to get the type of an expression in the editor, it says "(void-variable exedir=)". However, I can't even find the variable exedir when searching through the Haskell-mode documentation, and opening the Haskell process buffer shows that the lookup actually takes place and works.

screen shot 2015-02-27 at 08 50 15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.