Haskell has no variables, only constants, thus, you cannot use the same style as in other languages, with updatable values referring to the last. It does mean, however, that you can do some pretty awesome things, which you've tripped upon.
Take this declaration as an example:
myList = 1 : myList
When evaluated, this will refer to itself, thus doing this:
myList = 1 : myList -- but I'm referring to myList, so...
myList = 1 : (1 : myList) -- but I'm referring to myList, so...
myList = 1 : (1 : (1 : myList)) -- but I'm referring to myList, so...
myList = 1 : 1 : 1 : 1 : 1 : 1... -- etc.
The same goes for your constant y
:
y = y + 1 -- but I'm referring to y, so...
y = y + 1 + 1 -- but I'm referring to y, so...
y = y + 1 + 1 + 1 -- but I'm referring to y, so...
y = 1 + 1 + 1 + 1 ... -- etc.
GHCi can never completely evaluate the value of y
, because it's infinite, causing GHCi to hang.