[Haskell-cafe] Wishful thinking: a text editor that expands
function applications into function definitions
Duane Johnson
duane.johnson at gmail.com
Thu Apr 2 20:01:44 EDT 2009
So I was thinking about a "killer feature" for a text editor.
Wouldn't it be neat if you could expand function calls into their
definitions, in-place?
For example, suppose we have "minus" defined like so, somewhere in
another file:
> minus (a, b, c) (x, y, z) = (a - x, b - y, c - z)
Later, we make use of the function in our current context:
> let p1 = (1, 2, 3)
> p2 = (4, 5, 6)
> in p1 `minus` p2
By telling the editor to "expand" the minus, we get a temporary
replacing of the above with:
> (1 - 4, 2 - 5, 3 - 6)
Another example:
> parse s = map readLine ls
And supposing that readLine is defined somewhere else, moving the
cursor to readLine in the line above and "expanding" becomes:
> parse s = map (\line -> words $ dropWhile (== ' ') line)
This is all pretty standard for the kinds of things we do in Haskell
to work it out by hand, but is there any reason the parser couldn't do
this? I think it would be even harder to do automatically in any
other language. Maybe it's already been attempted or done?
Curious,
Duane Johnson
More information about the Haskell-Cafe
mailing list