[Haskell-cafe] Re: Haskell mode for emacs - some questions

Stefan Monnier monnier at iro.umontreal.ca
Tue Jun 19 14:51:31 EDT 2007

>> I finally got emacs using Haskell-mode working. It seems that the latest

Sounds like it was difficult.  Could you describe what you tried, what
didn't work, and what did work in the end?  Hopefully I can then improve
the doc.

>> - How can I just compile and run in one go without having to type "ghc
>> --make main.hs" as arguments for the "compile..." command and then typing
>> "main.exe" for "shell command..."? This is what you do all the time when
>> using Visual Studio, Eclipse, etc: just hit the F5 key which builds all the
>> dependencies and runs one or more generated executables. Easy. Visual
>> Haskell does this (in the cases it does not hang for some unknown reason).
>> Of course I could dig into ELISP, but somehow I feel this must be supported
>> somehow.

I never use GHC in this way, I always use GHCi instead.  Furthermore, I tend
to work on only parts of a program, so there isn't necessarily
a "main" function.  I'd be happy to add support for your usage pattern, but
since I'm not familiar with it, I'm not sure what to add.
Another problem is that unless your project is tiny, it'll have several
files and currently Emacs doesn't know which file is the main one.  I added
very-preliminary support for Cabal in the CVS code of haskell-mode which
should allow haskell-mode (at some point in the future) to figure out what's
the main file an how to compile it.
Currently all it does (other than font-lock the cabal file itself) is look
for the Cabal file to figure out the root of the project, so that C-c C-l
first does a "cd" to the root, which should allow dependencies in other
directories to work more seemlessly.

Patches (or precise feature requests) are very welcome.  E.g. it should be
fairly easy to add an "F5 binding" like you describe.  The main issue is how
to inform Emacs of what should be done.  In VS or Eclipse, what do you have
to do in order for F5 to work?  Is opening some random source file enough,
or do you have to select a Cabal file or what?

> Use C-c C-l to load the file into GHCi. This is better than just compiling
> it: you get an interactive environment in which to play around with, test
> out functions, etc. You can still 'run' your program by typing 'main'
> in GHCi.

We could also add a binding which sends "main" to GHCi.

>> - There seems to be support for "Haskell Font Lock Symbols", which should
>> convert \, -> and maybe other symbols to good looking Unicode fonts.
>> I can't get the correct fonts working on Windows.

I never use Windows so I can't really help you there.  Maybe ask on
gnu.emacs.help how to get those chars displayed.  I'm pretty sure Windows
has the needed fonts, so all that's missing is some way to help Emacs make
use of them.
If you figure it out, please send me a note about what you had to do, so
I can add it to the documentation.  

>> Now as I understood this is not really supported because of indentation
>> problems, as underneed the single Unicode arrow character is converted
>> into ->?

You slightly misunderstood: this hack is fully supported.  I just added some
warnings to the docstring to make sure the user doesn't blame me when he
gets bitten.

>> This is unfortunate, because that's one of the things I really
>> like about Sun's Fortress: the usage of Unicode symbols makes the text
>> look much more mathematically, versus the half-century-old ASCII text.
>> Furthermore in almost all Haskell books the richer font symbols are used
>> for clarity.  Any hints on this topic?

I use this hack all the time and haven't been bitten yet.  Some important
- the λ should use a 1-char-wide lambda (i.e. the unicode one).
  There's also a JIS lambda used if the unicode one can't be found, but this
  one is 2-char wide, so it risks introducing mis-indentation.
- the → and ← OTOH should use the 2-char-wide JIS arrow, rather than the
  unicode arrows for the same reasons.
- ...

> I wouldn't be surprised if this code had bit-rotted, or if there never has
> been Windows support.

I use it all the time, so it definitely hasn't bit-rotted (actually, it's
one of the most often updated part of the code).  There shouldn't need to be
anything special for Windows, but indeed I've never tried it on Windows
(and don't intend to either).

> It's a corner function, used by few and therefore not that polished. By
> all means, try it out, and if it doesn't work, feel free to submit
> patches, but I doubt it'll get changed any time soon by a haskell-mode
> developer :)

You'd be surprised,


More information about the Haskell-Cafe mailing list