The values ββin Haskell are immutable, so if you βadd an item to the listβ, you get a new list. Therefore in your code above
let allThings = Thingy first second allThings
Don't do what you expect. The top level of allThings is NoThingy , and this cannot change. The name allThings in let-binding does not apply to the top-level entity, it introduces a new binding that obscures the top-level name, and that the new name is also mentioned on the right side of the binding. So the string and the following equivalents
let theThings = Thingy first second theThings print theThings
The let binding creates a circular structure, referring to itself as one of its components. This means that, of course, printing will never end.
What you (probably) want to accomplish requires passing the structure you want to update as a parameter
loop things = do putStrLn "First Thing" ... let newThings = Thingy first second things print newThings loop newThings
And of course, as Nicholas said, you probably want to convert the input strings to values ββof the appropriate type.
source share