Class Framework for Collections : Draft

This page describes a proposal for a class framework for collection types. Related ticket: #666

Please give feedback on libraries at I'm especially interested in cases where this framework does not fit your application.

Goals, Non-Goals and Working Hypotheses

  • Focus on practical usage. No design in the abstract; what's proposed here shall be usable, and used.
  • Provide a clean separation between Collection and Data classes.
  • Reduce the amount of explicit module-qualification that is currently required for collection types usage.
  • Allow algorithms to be parameterized over collection types.
  • No attempt to fit updatable/state-monad-based collections. It looked like a bad idea to mix both updatable/non-updatable collections in a single classes framework. However, when updatable/state-monad-based collections are added, they should adopt much of the look-n-feel so as to avoid the IArray/MArray different-name-for-same-functions problem.
  • No attempt to fit 100% of the existing functions into classes. Some of them are just best left in the modules to be accessed qualified.
  • The classes are "implementation-based" (in opposition to the Edison idea).
    1. It seemed like a bad idea to do the same thing as something that already existed.
    2. Collections are (mostly) about performance anyway (otherwise everyone would use standard linked-lists).
    3. The type give information about the programmer's expected behaviour of the collection.
  • This deliberately uses many symbols already in the prelude. The intent is that the user hides whatever clashes from Prelude, however it's also possible to import this module qualified.
  • This uses functional dependencies. This is motivated by the fact that it gives a lot more expressive power without much inconvenience for the users. (note: We should consider porting this to Associated Types, since it's an alternative for FD in next version of Haskell.)
  • A single module is currently proposed, for ease of testing. The final version should of course be properly spilt into modules.
  • Most names of classes are only tentative and should be all reconsidered. Good ideas welcome.



  • Quite some functions are missing, they are omitted for the sake of brievety, until a consensus is reached on the main issues. They should be trival to add though. (eg. partition)
  • write instances for the new Seq type, following List.[]


Attachment below is outdated, but the library can be found on Hackage:

Last modified 12 years ago Last modified on Nov 28, 2007 9:02:06 AM

Attachments (1)

Download all attachments as: .zip