Scrapbook-0.4.0: code examples
Copyright© Frank Jung 2020
LicenseGPL-3
Safe HaskellSafe-Inferred
LanguageHaskell2010

Stack

Description

Use the MyState monad to implement a Stack.

Source: sdiehl/state.hs

Synopsis

Documentation

type Stack = [Int] Source #

Stack as array of intergers.

empty :: Stack Source #

Empty stack.

pop :: MyState Stack Int Source #

Remove element from top of stack.

push :: Int -> MyState Stack () Source #

Push element onto stack.

top :: MyState Stack Int Source #

Return element at top of stack.

tasks :: MyState Stack Int Source #

Example usage of MyState Stack. push & pop some elements onto the stack, and read the current top element.