Chapter 5. Implementing a Stack (FILO) in Haskell

Lets implement a stack based on lists. This example is to provide a quick tour of the language and to give you an idea of how modules are designed in Haskell.

5.1. Module and Export List

Haskell programs are broken up into Modules. In this case, we're going to implement a stack module. In this code snippet, we can see the name of the module (Stack) and the list of functions the stack exports. This is the abstract interface.

module Stack (
	      emptyStack,
	      push,
 	      pop,
	      top,
	      size,
	      listToStack,
	      isElement,
	      testStack
	     ) where