--
-- Abstract Data Types
--

{-- A Stack ADT
data Stack a

newStack :: Stack a
push :: Stack a -> a -> Stack a 
pop :: Stack a -> (Stack a,a)
isEmpty :: Stack a -> Bool

---}

module Main (main) where
import StackADT2 (Stack,newStack,push,pop,isEmpty)

main = let s1 = (push (push newStack 1) 2)
           (s2,e) = pop s1
           (s3,_) = pop s2
       in do print s1                       -- displays [2,1]
             print e
             print s2
             print (isEmpty s3)
             print (fmap (\x -> x*x) s1)
             print (fmap (\x -> x > 1) s1)  -- displays [True,False]
             print (fmap (\x -> x > 1) (fmap  (\x -> x*x) s1))  -- is equivalent to:
             print (fmap ((\x -> x > 1) . (\x -> x*x)) s1)

{--- Use. e.g., as follows:

% runghc stack-client.hs
[2,1]
2
[1]
True
[4,1]
[True,False]
[True,False]
[True,False]

---}