Skip to content

allow definition of functions in the interpreter

Right now, the only way to define functions is through the .hs files. Other interpreted languages such as Python allow the user to define functions in the command line. This is very helpful when one wants to prototype some quick functions.

One way to do it could be to detect when one declares the function and then enable a mode where one can add definitions. For example:

Prelude> x:: Int ->Int
*definition*> x a = a + 1
*definition*>
Prelude> x 10
11

Please consider adding this functionality to GHCI.

Thanks

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information