
Hello. I'm implement data structures (a stack, here) to get familiar with Haskell. It's not going very well. I have the following code... -- test.hs data Stack a = Top (Stack a) | Layers [a] deriving (Show) stack :: Stack a stack = Top (Layers []) push :: Stack a -> a -> Stack a push (Top (Layers ls)) value = Top (Layers (value:ls)) And I run the following in ghci... Prelude> :l test [1 of 1] Compiling Main ( test.hs, interpreted ) Ok, modules loaded: Main. *Main> push stack 4 Top (Layers [4]) *Main> let st = stack *Main> push st 4 ^CInterrupted. The output of the last command never resolves. I have to kill it. Might anyone have an idea why the push function is failing with st, but not with stack? I know there are other stack implementations that work, but I really want to know what's going on here. Thanks