Ticket #666 (closed feature request: invalid)

Opened 6 years ago

Last modified 9 months ago

Collection hierarchy proposal

Reported by: jpbernardy Owned by: jpbernardy
Priority: normal Milestone: Not GHC
Component: libraries/base Version: 6.4.1
Keywords: Data collections Cc: pho@…, merehap@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: N/A Blocked By:
Blocking: Related Tickets:

Description (last modified by jpbernardy) (diff)

Well, i am as user of libraries just wants consistency of using different data structures for the same tasks. for example, i want to have one indexing operator instead of !, !! and find. so, it's my hope-list:

  1. all collections are divided into 3-4 classes: arrays/lists, maps and sets. arrays/lists have sequential indexes in some range while maps have sparse indexes. also each class have an Updatable subclass
  2. collections in one class can be collected to each other with one (better universal) operator, such as:
    let list = cvt array
    let tree = cvt map
    
  3. collections can be converted to/from Updatable subclass with help of usual freeze/thaw operators
  4. all operations which are currently implemented in Data.List, Array.*, Map, Set, HashTable? modules must be bound to one of these classes, with duplicates (such as !/!!) removed. now i see the following class hierarchy:
    Collection (map, size, values)
      SetLike (union, diff)
        Set
        Map
      Indexed (indexes, !)
        Map
        Sequential (reverse, head)
          Array
          List (tail)
    

i give in parentheses examples of operations which are supported on each level of hierarchy

this will give possibility to write datastructure-independent algorithms and easily convert data to the data type which are best for each part of the program, smthg like:

a :: Map Int String <- read str
algorithm1 a
let b :: Hash Int String <- cvt a
algorithm2 b
c :: HashTable Int String <- thaw b
algorithm3 c

Change History

Changed 6 years ago by jpbernardy

  • keywords collections added; Collections removed

Changed 6 years ago by jpbernardy

  • owner set to jpbernardy
  • description modified (diff)

Changed 6 years ago by jpbernardy

solution is being built in [CollectionClassFramework]

Changed 6 years ago by guest

What about removing all reference to lists (plain type []) from the interface. E.g.

fromList :: [i] -> c   

should be something like

fromCollection :: Collection d j i -> c

Since we plan to have

instance Collection [a] a a 

this should be possible.

Same thing for toList. In fact, we don't need toList, since it *is* fromCollection, right?

Changed 5 years ago by igloo

  • testcase set to N/A
  • milestone set to _|_

Changed 3 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 3 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 2 years ago by PHO

  • cc pho@… added

Changed 21 months ago by merehap

  • cc merehap@… added
  • failure set to None/Unknown

Changed 9 months ago by simonmar

  • status changed from new to closed
  • resolution set to invalid
  • milestone changed from _|_ to Not GHC
Note: See TracTickets for help on using tickets.