[vector] #76: Vector cons typeclass error

vector vector at projects.haskell.org
Mon Feb 20 06:39:26 GMT 2012


#76: Vector cons typeclass error
--------------------+-------------------------------------------------------
Reporter:  mcandre  |       Owner:     
    Type:  defect   |      Status:  new
Priority:  major    |   Milestone:     
 Version:           |    Keywords:     
--------------------+-------------------------------------------------------
 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

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/76>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list