On Fri, 7 Feb 2003, Jeremy Gore wrote:
I've been poking around with Hugs, and at the same time also python's interactive interpreter. They are similar in a number of respects. After playing around with both I thought of some features t
In python, you can type in things at the command line and they will stay in memory (for instance, x = 13+4 outputs 21; type x again and it outputs 21, etc.) You can type in a whole program in this way. Unfortunately there is no way to save it afterwards AFAIK, a feature that should be implemented. In the case of Hugs, this seems a natural approach for a Haskell interpreter. Why not be able to type in functions and their type data at the command line to experiment with them? At the end of the session, the results of your experimentation could be saved to a file in the proper format (type info first, then function defs) to clean up and document. Or alternatively it would be saved to a preferences file of sorts, with the option of loading it automatically the next time hugs is started.
I suppose using :edit and :reload is pretty close to this, but building programs on the fly in this manner seems to me to be an extremely powerful approach with great potential usefulness in the real world. Is there any sort of Haskell (or other functional programming) shell out there?
A much simpler approach giving essentially all the benefits would be to have a signal (presumable OS dependant) which causes hugs execute a reload of the top level module (with the current accompanying loading of any imported modules which have changed) upon recipt of a signal of some sort, then arrange for that signal to be sent upon moving the mouse cursor into an evaluation window in a programmable editor (eg emacs). That way you can build a script using code in one window and move to an evaluation window to test things out, knowing hugs already has the latest version of your module. Apart from anything else, this avoids all the complications associated with trying to do `let' and `where' clauses that occur in Haskell. (I seem to recall reading in the python documentation that the interactive parser `almost always' figures out correctly when you've pressed Enter to move to a new line in a single input as opposed to signalling you've finished, implying there are cases when it doesn't get it right. Given that Haskell has an even less predictable grammar, due to examples like `add = sum (+)' and I suspect being able to enter non-trivial functions on the command line would be even more difficult to get right.) ___cheers,_dave_________________________________________________________ www.cs.bris.ac.uk/~tweed/ | `It's no good going home to practise email:tweed@cs.bris.ac.uk | a Special Outdoor Song which Has To Be work tel:(0117) 954-5250 | Sung In The Snow' -- Winnie the Pooh