Ticket #76 (closed defect: wontfix)
Vector cons typeclass error
| Reported by: | mcandre | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Version: | Keywords: | ||
| Cc: |
Description
I'm writing a function to convert a flat vector of pixel values to a vector of RGB tuples. It will have the type:
import qualified Data.Vector.Storable as V flat2rgb :: V.Vector Word8 -> V.Vector (Word8, Word8, Word8)
For some reason, Haskell reports a typeclass error, which I read as a failure to implement Vector.Generic.cons for all types.
$ make
ghc --make fuzz.hs -O2 -fforce-recomp -optl"-Wl,-no_compact_unwind" -package JuicyPixels -package filepath -package random-fu -package vector -package base
[1 of 1] Compiling Main ( fuzz.hs, fuzz.o )
fuzz.hs:24:23:
No instance for (V.Storable (Word8, Word8, Word8))
arising from a use of `V.cons'
Possible fix:
add an instance declaration for (V.Storable (Word8, Word8, Word8))
In the expression: V.cons (r, g, b) v'
In an equation for `flat2rgb':
flat2rgb v
| V.length v < 3 = V.empty
| otherwise = V.cons (r, g, b) v'
where
r = V.head v
g = V.head $ V.drop 1 v
b = V.head $ V.drop 2 v
v' = flat2rgb $ V.drop 3 v
Or maybe I'm doing something wrong.
Specs:
- vector 0.9.1
- cabal-install 0.10.2
- Cabal library 1.10.1.0
- Haskell 7.0.3
Change History
Note: See
TracTickets for help on using
tickets.
