-1

Is it possible to change a variable's value in GHCI debugger? If yes, please show me how?

user1532146
  • 184
  • 2
  • 14
  • 3
    No, one of the important design principles of Haskell is that *all* variables are immutable. – Willem Van Onsem Aug 02 '18 at 16:48
  • Possible duplicate of [In ghci, how to remove an existing binding?](https://stackoverflow.com/questions/44894152/in-ghci-how-to-remove-an-existing-binding) – Gurkenglas Aug 02 '18 at 19:57

1 Answers1

0

If you have a variable first defined as:

x = 7 :: Integer

Then if you want to redefine x, then all you need to do is:

x = "Hello!"

Note that this will not affect functions whose body contains x, for example:

> x = 7 : Integer
> f = (+ x)
> f 10
17
> x = "Hello!"
> f 10
17

You will have to redefine any function whose body contains x in order for the change to take affect.

Samuel Barr
  • 434
  • 4
  • 12