>> Would it be possible to supply a function of type String -> String
>> which is applied to every non-command input to Hugs? Of course, this
>> function should be the identity by default!
>
>Sounds like a great idea.  Some thoughts:
[big snip]

If you don't want to wait for HaskellAST to be implemented, here is a simple,
ugly but functional hack to achieve this effect.
Make a script called Preprocess.hs which looks like this:
  module Main where -- the Main is important!
  main = mapM_ (>>= putStrLn . preprocess) (repeat getLine)
  preprocess = reverse -- or whatever

And then run: 'runhugs Preprocess.hs | hugs'! (This is actually the shortest 
program I have ever written that does something useful :-)

This does the job, except both the raw and the processed input are send to the 
second hugs, you lose any command-line editing you might have and you probably 
need to do something to send commands through unchanged. 
Unless you program in palindromes, you're going to get some error messages... 
(BTW are there any Haskell expressions which are palindromes 
or meaningful when reversed, not counting the simple ones like 2+3*4*3+2 
etc.?)

As for the other question I posed in my previous message (adding variable 
bindings to Hugs), I've hacked Hugs to write all text prefixed by ':=' to a 
temporary file and then read it back. This is a *very* simplistic approach but 
it works most of the time - switching modules confuses the issue... 
In case someone is interested, I can put up my changed source files somewhere. 
Drop me a line (and you'll get the ':kompile' command thrown in for free!)

Bye, Jan de Wit


Reply via email to