diff --git a/crf-chain1-constrained.cabal b/crf-chain1-constrained.cabal
--- a/crf-chain1-constrained.cabal
+++ b/crf-chain1-constrained.cabal
@@ -1,5 +1,5 @@
 name:               crf-chain1-constrained
-version:            0.3.0
+version:            0.3.1
 synopsis:           First-order, constrained, linear-chain conditional random fields
 description:
     The library provides efficient implementation of the first-order,
@@ -36,18 +36,19 @@
     hs-source-dirs: src
 
     build-depends:
-        base >= 4 && < 5
+        base                >= 4        && < 5
       , containers
       , vector
       , array
       , random
       , parallel
       , logfloat
-      , monad-codec >= 0.2 && < 0.3
+      , monad-codec         >= 0.2      && < 0.3
       , binary
       , vector-binary
       , data-lens
-      , sgd >= 0.3.2 && < 0.4
+      , sgd                 >= 0.3.2    && < 0.4
+      , vector-th-unbox     >= 0.2.1    && < 0.3
 
     exposed-modules:
         Data.CRF.Chain1.Constrained
diff --git a/src/Data/CRF/Chain1/Constrained/Dataset/Internal.hs b/src/Data/CRF/Chain1/Constrained/Dataset/Internal.hs
--- a/src/Data/CRF/Chain1/Constrained/Dataset/Internal.hs
+++ b/src/Data/CRF/Chain1/Constrained/Dataset/Internal.hs
@@ -1,5 +1,8 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies #-}
 
 module Data.CRF.Chain1.Constrained.Dataset.Internal
 ( Ob (..)
@@ -30,17 +33,19 @@
 import qualified Data.Set as S
 import qualified Data.Vector as V
 import qualified Data.Vector.Unboxed as U
+import           Data.Vector.Unboxed.Deriving
 
 -- | An observation.
 newtype Ob = Ob { unOb :: Int }
-    deriving ( Show, Read, Eq, Ord, Binary
-             , Vector U.Vector, MVector U.MVector, U.Unbox )
+    deriving ( Show, Read, Eq, Ord, Binary )
+--           GeneralizedNewtypeDeriving doesn't work for this in 7.8.2:
+--           , Vector U.Vector, MVector U.MVector, U.Unbox )
+derivingUnbox "Ob" [t| Ob -> Int |] [| unOb |] [| Ob |]
 
 -- | A label.
 newtype Lb = Lb { unLb :: Int }
-    deriving ( Show, Read, Eq, Ord, Binary
-             , Vector U.Vector, MVector U.MVector, U.Unbox
-	         , Num, Ix )
+    deriving ( Show, Read, Eq, Ord, Binary, Num, Ix )
+derivingUnbox "Lb" [t| Lb -> Int |] [| unLb |] [| Lb |]
 
 -- | Ascending vector of unique interger elements.
 newtype AVec a = AVec { unAVec :: U.Vector a }
diff --git a/src/Data/CRF/Chain1/Constrained/Model.hs b/src/Data/CRF/Chain1/Constrained/Model.hs
--- a/src/Data/CRF/Chain1/Constrained/Model.hs
+++ b/src/Data/CRF/Chain1/Constrained/Model.hs
@@ -1,4 +1,7 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies #-}
 
 -- | Internal implementation of the CRF model.
 
@@ -29,6 +32,7 @@
 import qualified Data.Vector.Unboxed as U
 import qualified Data.Vector as V
 import qualified Data.Number.LogFloat as L
+import           Data.Vector.Unboxed.Deriving
 
 import Data.CRF.Chain1.Constrained.Feature
 import Data.CRF.Chain1.Constrained.Dataset.Internal hiding (fromList)
@@ -36,8 +40,8 @@
 
 -- | A feature index.  To every model feature a unique index is assigned.
 newtype FeatIx = FeatIx { unFeatIx :: Int }
-    deriving ( Show, Eq, Ord, Binary
-             , G.Vector U.Vector, G.MVector U.MVector, U.Unbox )
+    deriving ( Show, Eq, Ord, Binary )
+derivingUnbox "FeatIx" [t| FeatIx -> Int |] [| unFeatIx |] [| FeatIx |]
 
 -- | A label and a feature index determined by that label.
 type LbIx   = (Lb, FeatIx)
