Search code examples
haskellvectortemplate-haskellunboxing

GHC 7.10.2 warning when deriving Unbox instance using Data.Vector.Unboxed.Deriving


The following program:

{-# LANGUAGE TemplateHaskell, RankNTypes, MultiParamTypeClasses, TypeFamilies #-}

import Data.Vector.Unboxed
import Data.Vector.Unboxed.Deriving
import Data.Word

data Pixel a = Pixel a deriving Show

derivingUnbox "Pixel"
    [t| forall a . (Unbox a) => Pixel a -> a |]
    [| \ (Pixel a) -> a |]
    [| \ a -> (Pixel a) |]

main = print $ Pixel 0

Uses template haskell to derive an Unbox instance for Pixel. It worked on GHC 7.8, but on 7.10.2, I get the following warning:

/Users/v/haskell/Tests/pix.hs:11:1: Warning:
    No explicit implementation for
      ‘Data.Vector.Generic.Mutable.Base.basicInitialize’
    In the instance declaration for
      ‘Data.Vector.Generic.Mutable.Base.MVector MVector (Pixel a_a6Ue)’

What does it mean?


Solution

  • The vector-th-unboxed package that provides the template you're using has not been updated since basicInitialize was added to the Data.Vector.Generic.Mutable.Base.MVector class. You should file an issue to get the macro fixed, and you may wish to You should contact a Hackage trustee to see about getting the dependency bounds for vector-th-unbox adjusted in the mean time. Code written for recent versions of vector is likely to use basicInitialize (directly or indirectly); when that function is called with a Point, it will throw a runtime error.

    There is a pull request open to fix this issue, but the maintainer has not accepted it. You may wish to review it yourself and apply it locally.