validity
validity copied to clipboard
Instances for all vectors
- [ ]
Validity - [ ]
GenUnchecked - [ ]
GenValid - [ ]
GenInvalid
All different vectors in http://hackage.haskell.org/package/vector
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?
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.
@mxxo Did anything come of this? :)
No, sadly enough :( I had a little trouble building the repo and it fell by the wayside.
Ok :) Is there any way that I can help?
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
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.
For Hacktoberfest 2020 I'd like to take over this task.
@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.
Sure.