A pretty nice feature of shell scripting is “<<" operator.
It allows basically to launch interactive commands within a bash script.
For example I wanted to add a small but very useful function to textmate, I want to be able to know all the possible informations about a whatever function or data type.
The default info function in the haskell bundle unfortunately is only able to retrieve informations about prelude functions or functions used with the full path.
(eg Data.List.lookup and not simply lookup ).
Using ghci I should load the file (which automatically loads also the needed libraries) and type :info.
This is really easily done using “<<".
I added a command “info about” with the following code in my haskell bundle and now if the file is correct (it compiles) you are sure that you’ll get the informations about the function you’re looking for.
GHCI << EOF
:load $TM_FILEPATH
:info ${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
EOF
I also think that there should be a better way to communicate with ghci (and using System.Enviroment to get the arguments) but I didn’t find any, this solution even if not really elegant works pretty well.
This “approach” can be used also with many interpreters, sometimes I find it really useful.
Posted by petitesnouvelles