mhoare / elm-stack / Stack

This library implements a stack data structure in Elm, allowing you to worry more about your business logic and less about implementing common adts.

Definition


type Stack a

Initialisation

initialise : Stack a

Initialise an empty stack.

Common Helpers

pop : Stack a -> ( Maybe a, Stack a )

Removes the item at the top of the stack and returns it as the first item of a tuple.

push : a -> Stack a -> Stack a

Pushes an item onto the stack and returns the new stack. The item must be of the same type as the stack.

toList : Stack a -> List a

Convert a Stack type to a list data type

top : Stack a -> Maybe a

Returns the top element of the stack without removing it.