Skip to main content
2 of 4
added (monads) tag - if I missed something and it is not actually relevant to the question, feel free to revert my edit
Martin Sleziak
  • 4.7k
  • 4
  • 35
  • 40

What is the (Co)Monad for a Bag

A Bag is a data structure, like a list, that stores items with no concept of order. The only operations on the structure is to add an item and then iterate through the items with no guarantee as to the order of iteration. We see it in Sedgewick's Algorithms book. This has to be a Monad, as it is a data structure, and it could be Comonad or it could not be. What is the Monad for the bag? Is it a Comonad?

Ben Sprott
  • 1.3k
  • 14
  • 23