[TxMt] Haskell?

Paul McCann paul.mccann at adelaide.edu.au
Wed Nov 2 02:04:41 UTC 2005


Hi,

In a somewhat vain attempt to make this relevant to Textmate, let me  
thank everyone for the pointer to the Haskell bundle: like a few  
people I was contemplating getting my hands dirty and constructing  
something similar, but hadn't yet got around to doing so.

> If you are trying to use ghci or similar, You probably ran into the  
> same problem I did when I started trying the tutorials.  Apparently  
> you can not define functions in the interactive Haskell  
> environment.  The tutorials are not clear on that, and I really  
> don't understand why you can't do that.

You certainly can, but that's not the way in which ghci is really  
intended to work.

% ghci

[...banner deleted:   OK, let's define a function to join an array of  
strings with another string, or "" if fed an empty array.]

Prelude> let join a []=""; join a x =foldr1 (\x y ->x++a++y) x

Prelude> join " me " ["Show","money","hearties"]
"Show me money me hearties""

Even given this possibility, it probably more sense to write your  
functions/modules in a separate file and to reload that inside ghci.  
Just use

:l filename.hs

to load and a simple ":r" to reload after modifications. If you want  
to use Textmate to do the editing (surprise surprise) there's a shell  
escape available in ghci, so something like

:!mate filename.hs

allows a nice try/edit/try interface. That is, ghci is probably best   
viewed as *interactive* in the sense that you're "driving" your  
program, rather than *writing* your program. It's also a great  
environment for testing out one-liners for inclusion in larger programs.

Cheers,
Paul



More information about the textmate mailing list