PPP Exercises: Type operators and genericity
Exercise:
Use a type operator to define a generic stack type 'GenStack'. The type operator takes the element type of the stack as parameter:
Let
GenStack(E <:
Ok
) <:
Ok
= ...
Write a generic stack implementation for 'GenStack' as polymorphic function 'genStack' using 'list'.
Use these definitions to define 'intStack :IntStack'.
Summarize and compare the different definitions and implementations of stacks in the exercises
Generic abstract data types and implementations
,
Currying
, and in this exercise.
Ulrike Steffens
, 1994