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

peterv bf3 at telenet.be
Wed Jun 20 12:11:47 EDT 2007


> Sounds like it was difficult.  Could you describe what you tried

Actually, it was easy once I switched from xemacs to emacs... Of course, I missed the part in the wiki that xemacs does not work without some changes, mea culpa. The reason I used xemacs was because the previous version of emacs did not support good font smoothing (cleartype) on Windows, but that seems to be fixed now. Also, I just found out about the EmacsW32 package which is really easy to install on Windows. 

> currently Emacs doesn't know which file is the main one

So emacs has no concept of a "startup project" and a "solution" or "workspace" like Visual Studio and Eclipse? Well yes, that explains why this feature is missing. I guess I can just as will stick to typing "run" as the compile command and creating a run batch file...

> In VS or Eclipse, what do you have to do in order for F5 to work?

In VS you have a "solution" which is a set of "projects". A project is basically a module, which can be an executable or library. The user marks one or more executable projects as "startup" projects. When hitting F5, all the "dirty" dependent projects are compiled and linked, and all the startup projects are run. Usually you just have a single startup project. 

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

Would be nice. But I'll still have to use GHC a lot for performance.

> I use this hack all the time and haven't been bitten yet.  

Super! Then it's worth for me to figure out how that works. 

Thanks a lot,
Peter

-----Original Message-----
From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Stefan Monnier
Sent: Tuesday, June 19, 2007 20:52
To: haskell-cafe at haskell.org
Subject: [Haskell-cafe] Re: Haskell mode for emacs - some questions

>> 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
aspects:
- 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,


        Stefan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.9.1/854 - Release Date: 19/06/2007 13:12
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.472 / Virus Database: 269.9.1/854 - Release Date: 19/06/2007 13:12
 



More information about the Haskell-Cafe mailing list