isEmpty empty == True
isEmpty (fromList []) == True
isEmpty (fromList [ 1 ]) == FalseGet the last element added to the stack without modifying the stack.
top empty == Nothing
top (push 5 (fromList [ 4, 3, 2, 1 ])) == Just 5Add an element to the top of the stack.
push 1 empty == fromList [ 1 ]
push 2 (fromList [ 1 ]) == fromList [ 2, 1 ]Remove and return the last element added to the stack.
pop empty == Nothing
pop (push 1 empty) == Just ( 1, empty )
pop (push 2 (fromList [ 1 ])) == Just ( 2, fromList [ 1 ] )
A data structure that only allows adding and removing elements from the top, following the last in, first out (LIFO) principle.