The problem is that you need a dependent quantifier that is not currently available in Haskell. That is, the part (x : A)(xs : Vec A (suc n)) โ ... not directly expressed. You can probably cook something using singletones, but it will be very ugly and complicated.
I would just define
delete โท Eq a โ a โ Vec a (S n) โ Maybe (Vec an)
and be alright with him. I would also reorder the arguments to Vec to provide Applicative , Traversable and other instances.
No, actually. To determine delete , you just need to specify the index to delete:
{-
Note that x โ xs is nothing more than a rich typed index.
Here is a single point solution:
{-
Here we index Vec lists of their elements and save singletones as vector elements. We also define SEq , which is a type of class that contains a method that receives two singleton and returns either a proof of the equality of the values โโthey promote, or their inequality. Then we define the delete type family, which is similar to regular delete for lists, but at the type level. Finally, in the actual delete we map the pattern by x === y and, thus, show whether x y is equal or not, which forces us to calculate the type family.
user3237465
source share