purescript/purescript-lists

guarantee list sorting in type

matthewleon opened this issue · 3 comments

The insert function could accept a SortedList, whose constructor guarantees sorting, in its type signature. This could perhaps be accompanied by an unsafe constructor for creating a SortedList in contexts in which one is confident that the list is sorted.

Would probably actually also be useful for the type to keep track of the comparison function, allowing insertion into a SortedList to maintain the same type.

Will create a separate repo that tries to add this kind of thing as a separate library.

garyb commented

Linking the repo here for future reference: https://github.com/matthewleon/purescript-ordered-lists 😄