I read variables are immutable in haskell and something like the following does not work in haskell.
x = 30
x = x+1
But I still tried this to see what the compiler returns and I got the following :
The compiler just becomes unresponsive and does not do anything untill I press ctrl+c and interupt it.
Why does this happen and why the compiler becomes unresponsive instead of returning me some kind of an error?
Definitions in Haskell can be recursive, even definitions of values. When you write:
x = x + 1
That similar to writing this in Python:
def x(): return x() + 1
When you try to evaluate x
, your program gets stuck in an infinite loop.