From what I understand Foldable basically represents structures that have a number of elements of the same type that can be iterated over, i.e. lists, maps, sets, etc.
Is there a class like Appendable or Insertable which basically represents structures one can add elements to? Of course there would be no guarantee of the order of which elements are retrieved.
I’d rather not create a class myself if there already is one.
You should look at the Data.Collections package. It contains the
Unfoldabletypeclass with the following methods:It also provides the
insertManyandinsertManySortedmethods, to insert all the elements from aFoldableinto anUnfoldable.If you make your type an instance of both
FoldableandUnfoldablethen you can both insert and retrieve elements from it.