I am new to mac, and am in the process of getting my computer setup with all the programs I need, one of them being Haskell.
To my surprise, the Haskell platform for OS X is not like in Windows (where there is an GUI editor built on the platform installation - winGHiC). After looking a lot around, I found this editor TextMate which is supposed to be compatible with Haskell but am finding it quite complex to setup the Haskell Bundle for it.
I have already down开发者_如何学编程loaded and installed the following:
- Haskell Platform for Mac OS X
- Xcode 3.4 (Haskell Prerequisite)
- TextMate
- haskell.tmbundle files (mentioned above)
Is anyone familiar on how to get it working? It will mean a lot to me a detailed stepwise explanation, like I said, I has been only 1 day since I used OS X for the first time.
Thanks a bunch.
Well it's good work that you have found that the tmbundle is on Github these days.
You should be able to find the inbuilt options by clicking Bundles
, then Haskell
. There are fairly few in the standard Haskell.tmbundle
. The most obviously useful one is ... load file command-shift-r
or command-R
. If you have written a module with ending .hs or .lhs, it ... opens it in ghci.
(There was some talk of an integrated terminal in TextMate II, but who knows? One annoying feature of a non-integrated terminal is that one is tempted to 'reload' by clicking command-R rather than by doing :r inside ghci
; in certain frenzies it will develop that I have 15 copies of Terminal open.)
Many of the nice features are just general TextMate things, determined by the language description, so it might be good to read a general description of TextMate niceties. For example, if several lines are highlighed, then command-/ comments them out with --
s; or, if they are already commented, uncomments them. I had hacked together something to do this, long before I realized it was already there, not having studied the manual closely enough.
Everything has keybindings, of course, and it is very easy to add your own to run little scripts and insert little snippets, much more so than in Emacs, say.
Under Bundles
click Bundle Editor
and examine the text for different kinds of things.
So, for example, to make a tab trigger to start a language extension pragma {-#LANGUAGE ... #-}
where the cursor is in the space ...
make a copy of a Snippet
and substitute
{-#LANGUAGE ${1}#-}
selecting Activation: Tab Trigger
, and (say) LANG
as the trigger.
One nice thing is that they are all shell scripts, or else (like this one) partial shell scripts with some TextMate variables around, and you can pretty much write them in your own preferred language. (For the Haskell bundle I don't have any Haskell ones to speak of any more, but for other bundles I do.)
The syntax highlighting is surprisingly sound, but trips over a few fancy extensions, e.g. "PackageImports" , GADT syntax, markup for the Haddock documentation system, and some other oddities. I have hacked my own, but I find the format of the syntax files pretty unintelligible, so it's no use sending you a copy. The Haskell.tmbundle
has been emended by some knowledgeable Haskellers in the last two or three years. The person who first made it was just learning Haskell, and hadn't e.g. composed Haddocked modules, but on the other hand, he seems fortunately to have been very skilled and to have had an intimate knowledge of the TextMate machinery.
Notice by the way that TextMate stores the emendations you make in the Bundle Editor
in a rather strange way. The bundles that come with TextMate, e.g. C
, Ruby
, HTML
, LaTeX
, etc. are in /Applications/Textmate.app/.../Bundles
. The ones you install are in /Library/Application\ Support/TextMate/Bundles
. When you make emendations through the Bundle Editor
, they are stored in your local ~/Library/Application\ Support/TextMate/Bundles.
It sort of makes sense but it's a little complicated, and impedes public improvement of the Haskell bundle. (The one bundle I share with people, not the Haskell one, I keep in the lattermost, outermost directory under git revision, so the original and my emendations are together.)
The "Lookup on Hoogle" keybinding/option acts on highlighted terms; here's a replica for the hayoo website, which can search for uses of a type-signature
echo "<meta http-equiv=\"refresh\" content=\"0;
http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=${TM_SELECTED_TEXT:=$TM_CURRENT_WORD}\">"
If you cabal install hoogle, then you can make a local call to hoogle with a script like so:
hoogle --w --n=100 '${TM_SELECTED_TEXT:=$TM_CURRENT_WORD}'
choosing Save: Nothing, Input: Selected Text, Or: Word, Output: Show as HTML
Other emendations I have made are mostly trivial, like a tab trigger snippet for `{-#LANGUAGE ... #-} or else eccentricities of my own.
One thing worth mentioning that I managed to integrate is the typeof
executable from Hackage, cabal install typeof
, which runs to ghci for an inferred type signature. I have a key binding to show the inferred type as displayed bit of html, but also to insert it. It's a bit delicate but here is the text for the displayer of types
#!/bin/bash
word=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
module="${TM_FILEPATH}"
echo $word | typeof $module
choosing Input: Selected Text
, Or: Line
; Output: Show as Tool Tip
, Activation : Key Equivalent
(then choose a keybinding , mine is control-option-command-j
) Similarly, for type insertion via typeof
make a new C (command file) heading and include this:
#!/bin/bash
word=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
module="${TM_FILEPATH}"
echo $word | typeof $module | typeof_wordorder
# typeof_wordorder is the following hack compiled
# in my local ~/bin
# module Main where
# main = interact reword where
# reword :: String -> String
# reword xs =
# xs ++ (head . words . concat . lines $ xs)
Here typeof
and typeof_worderorder
are Haskell executables, the first cabal-installed, the second is the above commented idiocy, compiled in my local ~\bin
to get around some escaping nonsense. Here you should choose Output : Insert as Snippet
Sorry, I'm just thinking of random things. You should keep posting questions under this heading, as I think it would be worthwhile to see how one might trip up, but also what hacks our cleverer Haskeller friends may have thought of. I keep meaning to put a 'fork' of my tmbundle on github, but it's not too thrilling, and the organization of Bundle directories forever defeats me.
精彩评论