validity icon indicating copy to clipboard operation
validity copied to clipboard

Instances for all vectors

Open NorfairKing opened this issue 6 years ago • 10 comments

  • [ ] Validity
  • [ ] GenUnchecked
  • [ ] GenValid
  • [ ] GenInvalid

All different vectors in http://hackage.haskell.org/package/vector

NorfairKing avatar Sep 26 '19 11:09 NorfairKing

Hi, I'd like to try taking this on. It looks like there's some existing instances in src/Data/GenValidity/Vector.hs and src/Data/Validity/Vector.hs? Were you thinking about extending these files?

mxxo avatar Oct 03 '19 14:10 mxxo

Hi! Thanks, that would be great! Yes, there are existing instances there, and that's also where I was thinking of adding them. We could split up the module but I don't think that's necessary yet.

NorfairKing avatar Oct 03 '19 15:10 NorfairKing

@mxxo Did anything come of this? :)

NorfairKing avatar Oct 30 '19 18:10 NorfairKing

No, sadly enough :( I had a little trouble building the repo and it fell by the wayside.

mxxo avatar Oct 30 '19 23:10 mxxo

Ok :) Is there any way that I can help?

NorfairKing avatar Oct 31 '19 07:10 NorfairKing

It looks like making Validity instances is straightforward, since it boils down to "all the elements have to be valid".

I guess I'm a little shaky on how to base new vector instances off of the existing ones. Is there some special reason why MUV.Unbox and MSV.Storable were implemented in this first pass? Do you have any advice on which class constraints I should include for the other Vectors?

-- in validity-vector/src/Data/Validity/Vector.hs 

instance Validity a => Validity (V.Vector a) where 
    validate hs = annotate (V.toList hs) "Vector elements"                                                                                        
instance (MUV.Unbox e, Validity e) => Validity (UV.Vector e) where
    validate = delve "Vector elements" . UV.toList
instance (MSV.Storable e, Validity e) => Validity (SV.Vector e) where
    validate = delve "Vector elements" . GHC.toList   

mxxo avatar Nov 01 '19 14:11 mxxo

It looks like making Validity instances is straightforward, since it boils down to "all the elements have to be valid".

Well yes, and the internal structure of the vector also has to be valid. If a vector stores a length, that length needs to be positive, for example..

I guess I'm a little shaky on how to base new vector instances off of the existing ones.

you're on the right track.

Is there some special reason why MUV.Unbox and MSV.Storable were implemented in this first pass?

Someone needed those but not the others.

Do you have any advice on which class constraints I should include for the other Vectors?

I don't think you need any more constraints.

NorfairKing avatar Nov 01 '19 17:11 NorfairKing

For Hacktoberfest 2020 I'd like to take over this task.

sshine avatar Sep 28 '20 03:09 sshine

@sshine Go for it!

Just so you know: I don't think we've had a need for these instances yet because they haven't been written yet. I'll be making some more issues wtih a Hacktoberfest label before october. Maybe something else seems more interesting to you.

NorfairKing avatar Sep 28 '20 04:09 NorfairKing

Sure.

sshine avatar Sep 28 '20 14:09 sshine