FSharpPlus
FSharpPlus copied to clipboard
Conseable types
Is there a standard static member for types that are Conseable?
In principle anything that can be mapped to a List or Seq could be conseable. No?
Yes, looks like it can be added to the Collection abstraction which represents everything that is List-like but doesn't fit well in the Monoid or Foldable which are the preferred abstractions.
However I think its use will be more theoretical than practical since cons is an operation that is a bit tied to the structure, I mean for linked lists is natural and cheap but for sequences is not.
Do you have an interesting problem to be solved with a generic cons ?
This might be relevant: http://stackoverflow.com/questions/11437269/haskell-append-type-class
I felt like cons operator would be nice when dealing with List, DList and NonEmptyList
Vectors (#192) will also benefit from this.
What would be such generic operator or method name?
Maybe Unfoldable? (vectors are not going to follow the laws, though...)
So you mean to add the generic insert function?
Would insert make sense from a f# / .net perspective ?
To me insert sounds more like insert something somewhere in the middle.
It's not clearer than cons and snoc which tells exactly where the insertion is going to happen.
Perhaps that the abstraction should be called Unfoldable and then we could add cons or add.
Note that the name of the abstraction is only relevant for our docs as they are not reflected in the code, more than maybe a filename.